Some time ago I wrote an article of my backup solution using dar(1). But somehow this started to get itchy because dar is not really a portable format. Whenever something happens to my original files, I need dar in order to restore them. So was basically bound to quite specific tools.
That was the reason to start looking ahead. Criteria: incremental backups and quick access to my files. I considered tar(1) and rdiff-backup(1). tar(1) didn't seem to be the first choice. It can do incremental backups, but it's too basic. rdiff-backup offers both, but has the problem that I need quite a bunch of disk space somewhere else. I do own a external HD, but it is FAT formatted. Which means that rdiff-backup cannot properly operate on it.
But that didn't turn me down. My solution is to create a virtual harddisk on my FAT disk:
mkfs.ext3 -v -F /mnt/fat/backup.img
Now we can mount such thing (given that loopback support is enabled in your current kernel configuration). It is convenient to add mount and umount to your /etc/sudoers file, so you can mount and unmount with your own user.
Now execute:
And now we're ready to make the actual backup:
Which creates a backup folder on your image, with the contents of your $HOME. You can supply more command line options to the rdiff-backup command in order to include or exclude certain files or directories. That's up to you, refer to the manpage for more details.
When the backup was successful, you can unmount the image:
Repeat the mount, rdiff-backup and umount commands to update your backup. This will be an incremental backup. You may want to make a cron job for this, but you have to make sure that the FAT partition is always available.
Restoring one or more files is a brainless operation: just copy the files from your backup directory to your source directory. No need to locate and extract which takes huge amounts of time. Just copy.
It may happen that you want to restore older versions of files than the actual state in the backup folder. This is where the incremental backups kick in. To show all versions of a certain file in your backup, run this command:
Found 2 increments:
somefile.txt.2007-04-08T22:03:54+02:00.diff.gz Sun Apr 8 22:03:54 2007
somefile.txt.2007-04-09T00:05:56+02:00.diff.gz Mon Apr 9 00:05:56 2007
Current mirror: Mon Apr 9 11:05:56 2007
If you have picked the version you'd like to restore, run the following command:
So this will restore the file somefile.txt, like it was on 9 April 2007 to your home directory.
It is important to note that you do not modify your backup (modify, move or delete files). This may most probably result in faulty incremental backups later on.
Refer to the man page of rdiff-backup to see all options it has to offer.