in Software by (15.1k points) edited by
0 like 0 dislike

I have server on GNU/Linux OS and one of its tasks is to mirror/backup files located on server.

I know there are some conventions and Filesystem Hierarchy Standard like web pages go in /srv/www (/srv/http) or /var/www, but about backup there (in FHS) says nothing.

What is the best-practice/default location for storing the backup files on GNU/Linux OS?

Possible places I considered:

  • /var/backups - it is used for only internal backups of the OS
  • /home/backup - it is wrong to put the files in the same folder with personal user files because this folder exists only for users.

I am aware this question might be subjective, but I think what I do is quite common, and there has to be a convention.

where to store backups linux

1 Answer

0 like 0 dislike
by (15.1k points)

There is no default location for backup. In FHS 2.3 under the "Purpose" section of var, it explains why that's a bad idea to use /var/backup(s).

The proper place would be, dependent on the application and its usage, something like:

  • /var/lib/<app>/backups
  • /var/local/<app>/backups
  • /var/opt/<app>/backups

I say "something like" because whether you use /var/lib, /var/local, or /var/opt is dependent on the application, its role within the system, and how it was installed. Also, the structure under /var/lib/ is arbitrary based on the application maintainers.

Let's say that you are using rsync and that this machine is providing a backup service for the network, you would use: /srv/rsync/backups.

Folder /var/backup is for internal usage indeed. The Debian package system keeps an older copy from the last but one dpkg run in /var/lib/dpkg/status-old. In order to preserve the system for greater damage when a crash or filesystem corrupting occurs a daily backup is put into /var/backups when the file differs from the last copy. This is done from /etc/cron.daily/standard.

But there is no correct or wrong way to it (well, I discard the insane methods).

You can use next directories:

  • /var/srv_backup/www - files of sites
  • /var/srv_backup/db - dumps of databases of sites
  • /var/srv_backup/ftp - dump of ftp server
  • /var/srv_backup/svn - dump of svn

Please log in or register to answer this question.