25

There's a system-created /var/backups directory on Debian-based systems. I need a place to store backups of several git repositories (the primaries are on bitbucket). If I store them in /var/backup/git will that break apt-get, or will they get automatically deleted at inopportune times? Is there any reason I shouldn't use /var/backup? If there is, what is a reasonable alternative?

1
  • It is not dangerous to do so.
    – fpmurphy
    Mar 21, 2013 at 16:31

3 Answers 3

25

/var/backups is specific to Debian. It is not specified in the FHS, and its use is not documented in Debian policy (See Debian Bug report logs - #122038). The behavior is described in http://ubuntuforums.org/showthread.php?t=1232703.

While I agree with @fpmurphy that there is little danger of Debian ever removing your backup files in /var/backup, I think that it is not good policy to use a directory that is so Debian-specific. For one, Debian might change its policy and break things. For another, the user community already has specific expectations about what the directory is for. And finally, because it is not "portable" in the sense that it is not clear where this directory would be in a non-Debian distribution.

If my understanding of the FHS is correct, it would be appropriate to put clones of Git repositories in /opt/<project_name>/.git or in /usr/local/src/<project_name/.git. My personal inclination would be to use the former because it leaves the door open to backup project resources that are not source files and therefore not in Git.

If you really want to emphasis the backup nature of these repositories, you could put them in /backups, or even /home/backups, two directory names that are often used as mount points for external storage.

3
  • 11
    /var/backups actually is mentioned in FHS. It says that the directory is "reserved", but not much else: refspecs.linuxfoundation.org/FHS_2.3/…
    – Ajedi32
    Aug 12, 2015 at 16:16
  • /opt and /usr aren't really meant to be modified outside of software installation or other administrative activities, so anywhere inside those isn't really a great candidate. Something in /var would really be ideal, such as /var/local/gitbackup or even just /var/git. Dec 14, 2020 at 23:59
  • Further to Ajedi32's comment, the FHS says that reserved directories "must not be used arbitrarily by some new application, since they would conflict with historical and/or local practice". My reading of this is that they say it's inappropriate to put arbitrary backups in /var/backups. Dec 2, 2023 at 3:17
8

Nowadays, it seems the FHS suggests you can freely create whatever subdirectory under /srv, e.g. /srv/archives/bitbucket.
What I don't find really clear with the FHS definition is that backups aren't files "served by the system". Anyway, /srv is a free namespace.

1
  • the fhs gives examples of data expected to be there, such as FTP and www data. in the /srv section, they comment: "If the directory and file structure of the data is not exposed to consumers, it should go in /var/lib". That seems to apply to backups. Dec 2, 2023 at 2:42
-1

The best way to backup git repositories is to have a (bare) clone of the repository. git is quite frugal in its space usage, there will be almost no gain in compressing anything there. And a clone can easily be kept up to date (unless upstream does stupid pranks like wholesale history rewriting, nothing can be lost).

1
  • 2
    A git clone is a mirror, not a backup. Backup must preserve history. Although a version controller repository is itself designed to store history, as you wrote, it is not completely immune to failures/mistakes. See taobackup.com/history.html Dec 3, 2014 at 17:12

You must log in to answer this question.

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