Backing up with CRON and rsync

Everyone makes regular backups and so do you, right?

I run an Ubuntu desktop and I have set up nightly backups. Every day at midnight my /home directory is synchronised onto a dedicated backup drive using the following rsync command:

nice -n19 rsync -rltDuqAog --delete --exclude='*.gvfs' /home/me/ /media/backup

As you can see. I run rsync with a nice run-level of 19. This gives rsync basically the lowest priority, which is OK.

I then use a bunch of parameters. This is what they mean:

-r Copies directories recursively.
-l Copies symlinks as symlinks.
-t Preserves modification times.
-D Preserves device and special files.
-u Skips files that are newer at the destination.
-q Quiet. Don’t output anything.
-A Preserve ACLs (implies –perms or -p).
-og Preserve Owner and Group attributes.
--delete This is important. Basically rsync synchronizes files that have been changed. But what if you delete a file from the source? This option deletes it from your target as well, keeping both file systems truly sync’ed.
--exclude='*.gvfs' Excludes a particular file or directory. I had to add this since rsync would crash on this particular directory each time I ran it.

To be on the real safe side I would of course make a backup of the backup and if I would, I could of course use the same rsync command.

For more advanced rsync tickery, check out the post Easy Automated Snapshot-Style Backups with Linux and Rsync by Mike Rubel.

This entry was posted in System Administration and tagged , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.