off-topic: cool rsync tricks [was Re: Migrating /home from too small /dev/hda partition]

Tony Godshall <[email protected]> Tue, 12 Aug 2003 13:41:17 -0700
Newsgroups gmane.linux.hardware.sony
Message-ID <20030812204117.GA2751@sanity>
According to Vance Lankhaar,
> Like I just said in a previous email, try rsync. It does all that fun
> stuff too :)

A beautiful trick I got from the book "Linux Server Hacks"
is to make differential backups with rsync that look like
full trees but don't take any extra space.

Assume I want to backup host1:/usr to /backup/host1/usr and 
host2:/usr to /backup/host2/usr, and that the machines have
many of the same programs installed.

  rsync -e ssh -av faruser@host1:/usr /backup/host1/.
  cp -al /backup/host1/. /backup/host2/.
  rsync -e ssh -av --delete faruser@host2:/usr /backup/host2/.

Now I have backups of both, but files that are identical
take no extra space!

The caveat is that some timestamps will be wrong in /backup/host2.
This hasn't bitten me yet, but as a precaution I always do
do something like this after each rsync
  ls -lR /backup/host1/. | gzip > host1.ls-lR.gz

I also use this trick to perform differential backups.