On 10/18/10 8:28 PM, Bruce Labitt wrote:
   I'm looking to use rsync on a cron job to do some
'backup'.  I've read man rsync and a few 'tutorials'.  It
looks not too hard - this worries me.  :)

Anyone have a good/favorite tutorial on rsync that talks
about how to do this over ssh and avoids common pitfalls?
(like unmounted nfs...) lmgtfy, would not be too helpful.
Done that, checked out a few of them, looking for something
relatively understandable...

-Bruce
Bruce, using rsync like this is really fairly simple. I have found that the toughest part is to get your exclusion list right.

Here's the basics that will get you most of the way to where you want to go:

Use the -avz switch combination for recursive copying of a directory structure with compression and a report of what's going on.

Use --exclude_from=filename to specify a file containing things to not bother to copy. I generally use an exclude file when doing a cron-based rsync because it's easier to edit the file than the cron entry. So here's an example of the whole shooting match:

rsync -avz --exclude_from=/root/cronbackup-exclude /home/ remote.example.com:/backups/mymachine/home

I always set up ssh keys between the two machines so that the ssh connection automatically uses the keys to establish the connection. That way no password noise interferes with the cron job and your systems are more securely connected.

Things to note:

The trailing slash on the source parameter is CRITICALLY important if you want to get the kind of copying that you expect. It is equally as important to omit from the destination parameter.

On the remote machine I tend to have a backup area, usually because it's a NAS or somesuch, with directories for multiple machines. Thus the /backups/mymachine/home kind of path.

I find it really useful to use the ssh config file (~/.ssh/config as a general rule) to define Host shortcut names that I can use within the rsync command to shorten things when I need to connect to the remote machine as a different user or use a different port.

The exclusion list file contains one filename or shell glob per line. So you can use things like *.out or other shell wildcard expressions. You don't have to specify full paths unless you have multiple files with the same name and you want to copy some but not others.

Hope this helps!

Dan

<<attachment: coutu.vcf>>

_______________________________________________
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

Reply via email to