This wiki page contains a guide on how to set up hdup, "The little, spiffy, backup tool". (Don't be discouraged by the fact that on its website it says "Unmaintained!". It's mature program, and that warning means only that its author, Miek Gieben, develops and uses a similar program (rdup), which is a bit more difficult to use.) Although it's a command line program, it's easy to set up, so don't be afraid.
- archives are tar.bz2 (or tar.gz)
- incremental backups (monthly-weekly-daily scheme)
- backups over ssh
- encrypted backups (mcrypt, gpg)
Other backup programs
Let's list some other programs dedicated to making backups, grouped by "type":
- rsync type: Those which maintain a copy of the directory you want to keep a backup of, together with files which describe how did the contents change from the last backup (the so-called 'diffs'). Hence, they are inherently incremental, but usually they don't have compression/encryption. On the other hand, a working copy of everything is immediately available, no decompression/decryption needed. Finally the way it works makes it hard to burn backups to cd/dvd.:
- "just copy everything into one big archive, but support writing to cd/dvd"-type: backup-manager
- a one which has support for incremental backups, tarring and encrypting is duplicity. Functioning is very similar to hdup, but:
- the files backed up are "randomly" distributed between encrypted tar archives, which makes it harder to recover a particular file (hdup uses just one file: this is a drawback if you backup a lot of data at once)
- you can backup just one directory at a time (while with hdup you can specify as many as you want in one backup profile)
- another one which is similar to hdup: dar: it uses its own format for archives (so you need to have it around when you want to restore), but supports incremental backups, splitting backups into more files by size, makefile-type config files, some custom scripts are available along with it; supports basic encryption; some gui tools for inspecting backups are also available (kdar). Recommended ... a wiki page should appear soon :)
Installing and setting hdup up
- hdup is in [extra] repo, so you can install it via pacman:
pacman -S hdup
- We need to edit the configuration file /etc/hdup/hdup.conf. There's one supplied, so you can just edit that one; or you can use the minimal one listed here:
[global] # to which dir the archives will be written archive dir = /vol/backup # chown the archives to this user user = <yourusername> [my-comp] # what to backup, separate with ,. # For directories add closing slash, like /home/ dir = /home/,/var/abs/local/ # don't include theses directories exclude = lost\+found/, /proc/, /dev/, /sys/
- You need to modify at least the following options:
- archive dir: that's where the backups will be written to
- user: created archives will be chowned to this user; you can just use your username. This is needed since hdup needs to be run as root.
- dir: that's the list of directories whose contents you want to back up).
The rest of the comments about the config file can be skipped on the first reading. They describe various other options you can use if the hdup.conf file:
- You can have more that one profile (the one used above is named my-comp). This means that you can have a couple of independent backup schemes. For instance, you might want to have another one for your webpages:
[my-webpages] dir = /var/www/
- To have a simple means of excluding some directories, use the nobackup option. It specifies the filename, which if it exists in a directory, then that directory is excluded from backing up.
nobackup = .nobackup
This can be used for example to exclude backing up of opera cache, by creating and empty .nobackup file in the cache directory:
- You can specify the compression algorithm used:
compression = bzip compression level = 6
- hdup refuses to restore backups to / by default, since it can be dangerous. To override this, use
# allow restoring to / force = yes
Let's first explain the monthly-weekly-daily scheme of backups. The 'monthly' archives contain all the data you specify to backup. The 'weekly' archives contain only those files, which have changed from the last 'monthly' backup. Finally, 'daily' contain only those which have changed from the last 'weekly' backup.
Of course, 'monthly', 'weekly' and 'daily' are just names, you don't need to perform backups in these intervals. But you cannot perform a 'weekly', unless you have at least one 'monthly', etc.
So, how does hdup implement this scheme?
As root, you can run hdup with the command like
hdup monthly my-comp
This creates a directory 'my-comp' in the directory you specified in the config file (/vol/backup), and inside it two other directories: 'etc' and (current date) '2008-02-23'. The 'etc' one contains some hdup's files, and the '2008-02-23' one will have a big .tar.bz2 archive in it. That's your backup.
After some time after 'monthly' backup, you decide you want to backup again. Now you can run hdup as
hdup weekly my-comp
and hdup will archive only what has changed from the 'monthly', and the archive will be put into another dir named after current date in /vol/backup/my-comp.
It should be clear now how the backing up works. Note that if hdup cannot find a 'monthly' and you ask it to do a 'weekly', it will complain. See the tips section.
To restore, you need to have all 'parent' archives (ie. if you want to restore a weekly backup, you also need to have its 'monthly' available). The command for restoring is
hdup restore my-comp 2008-01-31 /somedir
With this, hdup will try to restore things as they've been up to the date specified, and it will unpack to the directory /somedir. You can force it to unpack right away to / (see 'force' option above), but be very careful with this!
Note that the backups are just .tar.bz2 archives, so if you need a particular file from a particular date, just use any archive manager (or tar and bzip2) to open the archive and copy the needed file over.
More goodies: encryption and ssh
If you've got here, let me remind you that man hdup and man hdup.conf are your friends!
- For gpg encryption, you want to add something like
algorithm = gpg key = <your gpg key identifier>
either to [global] (then it's going to be used for all profiles), or just to a profile part. The archives will then be encrypted with your public key (so you can only decrypt them with your secret key). Note that you can decrypt them manually with
gpg -d <archive file>
in case you need it.
- For other encryption (e.g. mcrypt), just add
algorithm = mcrypt
In this case, hdup will ask for a password both when archiving and restoring.
I haven't tried the backups over ssh... so if anybody feels like, please update this wiki.
- You can of course burn the archives to cd/dvd with any burning software you like. The only thing to remember here is that the 'parent' archive is needed when you're doing a 'child' backup (like you need 'monthly' for 'weekly'). However, if you're tight on space, this can be achieved by mounting the cd/dvd with 'parent' backup, and soft linking its directory into /vol/backup, so that hdup can find it there.