Posts Tagged 'rsync'

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 ^^