Incremental backups of linux boxes using rsync

Incremental backups of linux boxes using rsync

rsync is a great tool for running backups. When running multiple backups of the same file, rsync stores the data only once unless the data have changed. In the latter case, only the file deltas, i.e. the difference between the two files, is transferred, which can save both transfer time and bandwitdh.

One really favorably effect of running rsync like this is that you can browse the backup folders afterward, and each backup will look like a full backup. So just as easily as browsing any folder structure on your disk, you can browser the different backups of your system. 

Below is a very simple rsync shell script to show how a rsync backup script might look like. It’s very primitive, but can easily be extended to take parameters or any other functionality one would like. The current script does basically this:

  1. Rotate the backups
  2. Run incremental backups. Unchanged files and folders are simply linked to the corresponding files and folders from the last backup.

This is the script:

In the script above I’ve set the destination to be my external USB disk drive, which I use to hold my backups. As rsync will try to preserve ownership, permissions and so forth, I recommend formatting your destination file system with a similar file system type (typically ext3 or etx4 for the most common linux distributions) as your source file system(s).

6 thoughts on “Incremental backups of linux boxes using rsync

  1. Yeah, that script you linked to was really neat. Might consider making use of that myself one day. 🙂

    – Kenneth

  2. my favorite rsync options: (remove -n after testing a dry-run):

    rsync -n -HaxS –numeric-ids -zyc –bwlimit=5000 -vPh –stats -e’ssh -o ServerAliveInterval=60′ –delete –delete-delay –delete-excluded –exclude myfile SRC/myfolder/. DST/myfolder 2>&1 | less -S+F

  3. I look a quick glance at your script, and it looks really great. Much more sophisticated than my simple script. Worth checking out!

Leave a Reply

%d bloggers like this: