21

I have an Ubuntu Server and one of its "tasks" is to mirror/backup files located on another server in a different location using rsync/rdiff-backup.

I know there are some conventions like web pages go in /var/www.

What is the best-practice/default location for storing the backup files?


Possible places I considered:

/var/backup - looks like it is used for internal backups of the OS

/home/backup - I could create this directory, but if maintaining backups is a "service" this server provides, I feel it is wrong to put the files in the same folder with personal user files

PS I am aware this question might be subjective (I got the warning tooltip), but I think what I do is quite common, and there has to be a convention.

2 Answers 2

34

There is a proper location.

There is a standard for proper filesystem structure. Its current version has been around for over a decade, which might be news to some Linux distros.

The latest version of the Filesystem Hierarchy Standard is 2.3: http://www.pathname.com/fhs/pub/fhs-2.3.html

There, under the "Purpose" section of var, it explains why that's a bad idea to use /var/backups:

Several directories are `reserved' in the sense that they must not be used arbitrarily by some new application, since they would conflict with historical and/or local practice. They are:

/var/backups
/var/cron
/var/msgs
/var/preserve

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/<app> is arbitrary based on the application maintainers.)

By the way, since you mentioned it, /var/www is not the proper place for served web pages (again, this is news to some distro and package maintainers, but the FHS is older that many of them who clearly never have read it). Served content, and stored application data/assets for services belong under the /srv directory. I have been using the protocol method since 2005 and find it works quite well (/srv/http, /srv/ftp, /srv/git, /srv/svn, etc.).

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

/srv/rsync/backups

UPDATE

Version 3.0 of FHS: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html

6
  • 1
    In the end I actually decided to use /srv/rdiff-backup next /srv/git and /srv/svn and I am glad you confirmed this is the correct decision.
    – andi
    Apr 6, 2016 at 7:06
  • 1
    The Filesystem Hierarchy Standard 3.0 (March 19, 2015) is here refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf Dec 6, 2019 at 0:46
  • 1
    Thanks, Emerson. Dec 7, 2019 at 1:20
  • Thanks, Dario Seidl, for the corrections/edits. Nov 30, 2020 at 17:43
  • So if I understand correctly: Suppose I have 2 computers. I backup (some app's) Computer1 locally to /var/lib/rsync/backups and then I could sync that to Computer2 at /srv/rsync/backups/computer1? i.e. "var" is for local backups and 'srv' for remote?
    – Bert
    Aug 22, 2023 at 11:01
3

There is no default location.

I would not use any of the regular directories for this. Keep the server clean from outside backups and put those is a clear defined location.

Most likely I would use a removable disk and mount it. Something like /external_backups/ or /media/external_backups/ and inside that subdirectories with the server name and inside those compressed tar files.

/home/backup feels wrong; I would leave /home/ itself for users. If you want to do it this way I would create a user "backup" and the same setup as above.

Something like this (2x with a partition, 2x from a /home/backup/:

  • /external_backups/AS400/20150101/backup.tar.gz
  • /external_backups/AS400/2015_01_01.tar.gz
  • /home/backup/AS400/20150101/backup.tar.gz
  • /home/backup/AS400/2015_01_01.tar.gz

/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. (By default:) 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: like putting them in / or in /boot or something else as crazy as that).

1
  • The server is in a data center, so external storage is out of question. I will create user backup and I will use its home folder for backups. But now I know I there is no name convention I am breaking.
    – andi
    Jan 20, 2015 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .