Backups with rsync

My hard drive begins to make strange noises, so I decided to make a whole system backup today. Unfortunately I always forget the rsync parameters and have to look them up in the man page. But this time I was clever enough to write a small bash script which does the job for me. My backup files are stored on a portable USB hard drive which uses FAT32. This means permissions are lost and the maximal file size is limited to 4GB. Restoring a Linux system from FAT32 can be quite annoying, so I won’t get around buying a new hard disc and format it with ext3. However the benefits are an easy access from other (probably windows) machines, so I can take the hard drive to my windows-using friends and share the latest holiday pictures while having an up to date backup on the disc at the same time.

To make rsync doing the job for me, I just needed to run

 rsync -avu --max-size=4GB /from/path/ /to/path/

It is very important to put the slashes at the end of each path parameter, otherwise rsync will try to make a copy of /from/path within /to/path resulting in a /to/path/path directory. The “-avu” parameter list means:

  • -a archive mode
    rsync will try to preserve symbolic links, file attributes, permission, time stamps etc… it doesn’t really make sense in my specific scenario, but I plan to get myself a ext3 hard drive for backups, so it doesn’t hurt and is shorter than “-rtl”
  • -v verbose mode
  • -u
    this flag will make rsync skip files which are newer on the backup system, in every other case files will be send to the receiver if time or size doesn’t match

With these options I was able to quickly save my whole ~/projects ~/media ~/data directories on my USB disc without copying files to the disk which were backed up before.

Let’s hope I will never need my backup ^^

Advertisements

1 Response to “Backups with rsync”


  1. 1 florian May 10, 2009 at 4:57 pm

    well, you could create a splittet tarfile as a full backup:

    # cd /
    # tar -pc home/ | split -b 1G -d - /media/usb/PREFIX_tgz.
    

    will create files like this:

    -rw-r--r-- 1 fls fls 1,0G 10. May 18:54 PREFIX_tgz.00
    -rw-r--r-- 1 fls fls 1,0G 10. May 18:54 PREFIX_tgz.01
    

    and you can extract them via:

    # cat /media/usb/PREFIX_* |  tar pxz
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: