[Ilugc] Automatic backups with rsync and cron

  • From: siva@xxxxxxxxxxx (Sivasankar Chander)
  • Date: Sun Jul 25 09:57:00 2004


rsync is a real luxury.  Thanks a lot! I found the document at 
http://www.tldp.org/LDP/LGNET/current/odonovan.html useful in setting up ;
my automatic backup.

There have been some recent (~last 18 months) improvements to rsync that
greatly simplify some the scripts related to rotating backups. Check out
the techniques and scripts in:

http://www.mikerubel.org/computers/rsync_snapshots/

The main idea is that you can have an unlimited number of snapshot
backups using only about 2 times the size of the data that you want to
backup, i.e. it is O(1) in space, regardless of the number of previous
backups that you want to keep. This magic is accomplished by keeping
only the changes, and using hard-links for every file that hasn't changed.
One of the added benefits is that when the data hasn't changed much,
the backup is instantaneous, unlike approaches that use 'cp -al' and
so on (note that incremental backups with rsync are much faster, but
the first or seed backup takes about the same amount of time as
conventional approaches. But the seed backup is performed only once).

This is a classic computer-science pointer-manipulation optimization,
similar to copy-on-write, lazy eval, RCU, etc., that gives enormous
speedups over traditional approaches (think of a Micros~1 tape or
CD backup that may well be a  *million* times slower for the same
amount of data. One of the show-piece examples where open-source
obliterates closed-source). 
 
It's not the last word on the subject, but it gets pretty close. I've
streamlined and generalized the scripts considerably, and have even
managed to squeeze them into an embedded-Linux NAS device, in all of
~200k for the rsync executable and about ~2k for the scripts. I'll
post the scripts after they undergo some more testing, but for now you
can use the scripts in the link above, which should be OK for all versions
of rsync.

If you want the recent fixes, use rsync-2.6.2. In particular, the --link-dest
option of rsync is one of the crucial new features. (There is a Trustix srpm
for 2.6.2 that also rebuilds fine for RedHat, for all the rpm junkies like me).

-Siva 

Other related posts: