server backup has always been the bane of a systems administrators’ existence… and finding the right backup utility and media is even worse! would you rather go for tape or writable CD? how about a magnetic drive? or a ZIP drive (that is, if you can still find these guys!)? and when do i backup? every night whenever no one’s around? or early in the morning? so does that mean i have to be here during those times?
okay, the long and shot of it is a big “NO”! that is if you are using rsync!
rsync, “is a tool for efficiently transferring files across a network”, this according to its documentation. but for me, this can be further written as “a tool to efficiently back up data across a network”… this is how it works:
we know that there are two types of backup; full backup and incremental backup (okay, three if you consider differential backup which to me, is not much different with incremental, except that you’d have to update the archive attributes yourself). for a further explanation on what these procedures are, please go to http://www.no-panic.com/backup/tech_supt/Procedures.html. we will be assuming you already know the differences between these procedures…
to use rsync, all you need is an idle box (installed with Linux, of course) and the rsync package installed on both the idle box (box A) and the server (box B) you want to back up. now, from box B, find out the specific files or directories you want to copy, and from box A, where you want to copy them to. it would be good practice to put the files in box A to where it was in box B, as you will find out later on.
and then, simply run this command from the console of box B:
rsynx -vupogtH -e=ssh /path/to/backup [ip/hostname]:/where/to/backup
and then, it will ask you for root’s password on box A, where:
-v = increase verbosity (of output/messages)
-u = update only (don´t overwrite newer files)
-p = preserve permissions
-o = preserve owner (root only)
-g = preserve group
-t = preserve times
-H = preserve hard links
-e=ssh = the connection protocol to use
/path/to/backup = the exact path of the files or directories you want to backup/copy (source)
[ip/hostname] = IP or hostname of the box you want to copy to (or from if done the othre way around)
where/to/backup = the exact location where you want to copy the files/directories (destination)
so, for example, i’d want to backup all directories under the home directory of my box B to the home directory of my box A having an IP of 192.168.0.2, my command would be:
rsync -vupogtH -e=ssh /home/* 192.168.0.2:/home/.
and this will copy all files during the first backup (full), and will only copy newer files during succeeding backups (incremental). read the rsync documentation or do “man rsync” on your linux console for more information on the flags of rsync.
for the actual backup to happen (incremental), what you can do is put the command you use in crontab and let it do the work for you… yes, even at 1 in the morning without the need for you to be at the office and running the command manually. click here to find out more about crontab.
now, for the best part. if, suddenly, box B decides to crash, you still have box A, with the exact same image (if you do everything right)! all you have to do is change the IP of the new box (box A) to what it was for box B, and voila! minimal downtime experienced and no need to copy from a backup image all the data you need (or want, or whatever)… nifty, eh?
so, the next time you are thinking of backing up your data and want full redundancy (okay, partial then) of your servers and its services, look at rsync… i guarranty that you won’t go wrong…
UP NEXT: dancing the Samba with Linux
current disposition: very happy i was able to do something very informative… not my usual drivel and ramblings… ehehehehe…
Ciao, baby… 8-)