**This is an old revision of the document!**

Backing Up with Rdiff-Backup

TL;DR
1. Format a big drive as UDF.
2. Install rdiff-backup
3. rdiff-backup –exclude-globbing-filename $HOME/.excludes $HOME /path/to/drive
4. Automate that command with cron

There are several good backup applications aimed at local and network backups. Some are geared toward sys admins managing entire VFX houses, others are geared toward the advanced home user, and still others are aimed at regular, humble, everyday artists like us. No matter the audience, the best solutions can be automated so that you don't have to remember to do it, or wait for huge data dumps when you finally do remember to backup. A steady, automated, “always on” backup scheme tends to be the smartest backup plan.

The most straight-forward and flexible backup application available is rdiff-backup, available from http://slackbuilds.org. It has one dependency, librsync, which is also available on slackbuilds.org.

This section assumes that you are interested in backing up your personal data, not the entire system, since the OS is free and can be re-constructed.

There is a case for backing up the entire system (quicker recovery in the event of a full system disaster being the main one), and this can be done; just replace /home/$USER in this chapter with / and run your backups as root. See http://rdiff-backup.nongnu.org/docs.html for more information on what directories you should exclude when doing a full system backup.

Rdiff-backup is a terminal command only; it has no graphical user interface. If you are not comfortable using the terminal, it's still ok to use rdiff-backup because the point of it is that you don't have to use it much; you automate it. That's what we'll do together here, and once you get through this chapter, you will never have to use rdiff-backup directly again, except to recover data but under those circumstances, you probably won't mind learning a new command or two.

If you still doubt this prescription, you are welcome to try out LuckBackup but be aware that fancy graphical (luckybackup included) are more subject to change than backup commands, which have often been around, basically unchanged, for decades. If longevity is not a concern, feel free to explore different backup options than what Slackermedia recommends.

Rdiff-backup Plans

Local Backup

☛ If you own the drive to which you want to backup, then do these steps before continuing.

☛ If you run your own home server (or you otherwise have physical access to the server acting as your backup destination), then this setup should occur on the server, not your local computer.

☛ If you are backing up to a server off site that you have no physical access to, skip this entirely and read the section on remote backups.

1. Format your hard drive to be used as a backup drive.

If you are intimately familiar with hard drive formats (“file systems”) and have your own preferred file system, you may use that, but Slackermedia recommends the UDF file system for your backup drive because it is easy to configure, it handles large drives well, its paths are easy to specify, and it is universal so that no matter what you have available to you, you can get to your data.

Read the section on udf to learn how to safely create a UDF drive. Give your UDF drive an id of safehouse (–vid=safehouse).

When you format it, give your UDF drive an id of safehouse (–vid=safehouse).

When coming up with a naming scheme for your backups, it's best to use a unique (but sensible) term, because the word “backup” gets used so frequently by so many applications. You want to be able to recognise your backup, so pick a somewhat unique name for it; look in a thesaurus or use your artistic creativity to think of a word that means “backup” (examples: carbonite, keepsafe, safehouse, vault, bunker, silo, attic, booty, hoard).

Slackermedia uses the naming scheme “safehouse” as the backup location. This avoids confusion over whether we are talking about “backup” the action or “backup” the place, and so on.

2. Add the drive to /etc/fstab.

There are several advantages of doing this; it will make the drive automatically mount if it is attached at boot time, and it also ensures that you have an easy way of finding your backup location no matter when the drive is attached.

First, add a directory for the drive. This will make the drive more integrated with the system (meaning that your computer will not have to create dynamic directories for it in /run/media as it does for most external drives).

$ su -c 'mkdir /safehouse'

Next, add the drive to the file system table, located at /etc/fstab. Open this file in your favourite text editor with kdesu and add this line to it (it's ok to copy and paste this exact line; it is verbatim what you should add):

LABEL=safehouse     /safehouse    udf   user,rw  0 0

Save the file and reboot to make sure that the drive mounts automatically if connected. Technically, it's not necessary to reboot, but you might as well reboot just to verify that all goes well.

3. Perform an initial backup.

The first backup is the largest and slowest backup because it is copying everything over to your backup drive. Subsequent backups will be much much smaller, because it will only copy changes to that base layer.

It is vital that this initial backup is done the exact same way it's going to be done on all future backups, for many reasons, but essentially because you need to get confirmation that everything has been set up correctly before you try to automate it. If you do a backup with a drive connected to your computer, and then try to switch to a networked backup, you might do user permissions wrong, or file paths might be inconsistent, or any number of problems, and you won't ever realise it because you'll have automated the process, never knowing that all you have automated is failure.

Do not do that.

Make your first backup the initial test of your backup process. If it fails, refine your process, troubleshoot, and try again. When you get it right, you'll know it, and you'll know exactly what to automate.

The basic command to backup your home directory (where all of your personal data lives):

For a locally attached drive:

$ rdiff-backup --terminal-verbosity 8 --print-statistics --exclude-globbing-filelist /home/klaatu/.excludes /home/klaatu/ /safehouse/klaatuWork/

You might have exclusions that you don't want to have backed up (for instance, do you ever want your trash bin backed up?). For this, read the section on exclude options.

Or for a server:

$ rdiff-backup --terminal-verbosity 8 --print-statistics --exclude-globbing-filelist /home/klaatu/.excludes /home/klaatu/ klaatu@10.1.1.11::/safehouse/klaatuWork/

Notice that the server path contains two :: between the hostname and the destination path.

This command backs up your entire home directory to the /safehouse location. Do not bother creating the destination file (in this example's case, the /safehouse/klaatuWork folder); rdiff-backup will [attempt] to create that for you and warn you if it cannot write to the drive.

No matter what, your first backup will take a long time, so just let it work. </WRAP>

You have completed the setup phase.

Backup to a Local Drive

If your computer is a workstation (or “desktop” or “tower”) then it makes sense to backup your data to a drive that you just leave plugged in to the computer. The advantage is that the backups occur in the background, without any special action required of you. The dis-advantage is that the drive is physically connected to your computer, so if accidentally erase your entire computer and everything connected to it, then you have blown away both your data and the backup copies of your backup data (the likelihood of you devising such a command by accident is extremely rare).

As with any local backup, this method also is not fire-, flood-, or Velociraptor-proof. That is, if something catastrophic happens to your house or apartment, then your data is gone and so is your backup.

On the other hand, if you accidentally delete a file an hour before your deadline, you can pull the most recent version off of a drive sitting under your desk and move on with your life.

As always with devising a backup plan, the cost-to-benefit factor is your own to ponder.

The backup scheme for such a setup is simple.

1. Verify that the drive has been mounted to /safehouse as expected:

mount | grep safehouse

If nothing is listed, then the drive has not mounted successfully. Verify that you have labelled it properly with the vid flag (if using UDF as recommended; if you are using ext{2-4}, try using e2label).

2. Change a file or add a new test file, and then run the your backup command again.

$ rdiff-backup -v 8 /home/klaatu/ /safehouse/klaatuWork/

This time, the process is relatively fast, since it has only copied over the changes.

☛ You might have exclusions that you don't want to have backed up (for instance, do you ever want your trash bin backed up?). For this, read the section on exclude options.

☛ Assuming everything is working as expected, automate the process and never think about it again.

☛ For information on recovering data from a backup, read the section on restoring files.

<a name=“connect”

></a>

=