Sunday, August 14, 2011

Backup with rsync

The beauty of open source is in the wealth of tools available. Most Linux distributions should already come with rsync by default. The rsync man page describes it as a "fast, versatile, remote (and local) file copying tool". That's really the simplest and best way to think of it.

It's a good idea to keep backups of your files. Even the configuration files in your /home folder are important. If you've used Ubuntu for a while now you'll have things set up just the way you like it. It'll be a pain to redo everything all over again in case you need to do a clean install. Even if you don't mind redoing everything from scratch, it's way faster to just restore everything from backups.

Using rsync is simple. Just stick to the essentials. Nothing fancy needed to get a fully adequate backup.

~$ rsync -Cavz /source/ /destination

Replace /source/ with the full path to your /home folder, and /destination with where you want to copy those files to.

Some good rules to follow (as a guide):

Keep it simple. Open source tools, especially terminal commands, are really powerful. If you're good at shell scripting you could do all sorts of "magic" with them. But, for starters, let's keep things simple. No need to go all fancy. Just start with something simple that works. You can always improve on it later.

Backup to a different hard disk. Storage is really cheap nowadays and it's getting cheaper all the time. Getting a 2nd hard disk or a external hard disk for backups isn't too costly. Storing your backups on a separate drive means your data will more likely survive a filesystem corruption or hardware failure.

Automate it. Regular backups ensure your backup stays relevant. People tend to forget to backup so maybe setting up a cron job to automatically do it for you might be a good idea.