4

I'm looking for an alternative to using this, it doesn't have to use FTP, but it should provide the same functionality as the "--mirror" option of wget where it only downloads new and changed files.

wget --mirror --preserve-permissions --directory-prefix=/hdd2/website-backups --exclude-directories=special,stats --ftp-user=user --ftp-password=pass ftp://ftp.domain.com

Currently the above command is how a remote site is being backed up every few days via cron job on a home server. The remote site has moved to a new host with SSH available and I've already got public/private keys setup for SSH. Now I would like to use something a little more secure than wget/ftp for the automated backup, but since this site has a lot of image files most of which will not change, I don't really want to zip up the entire documentRoot and download it every time.

1 Answer 1

8

rsync is the standard utility for this:

rsync -avz -e ssh source/ user@destServer:/dest/
  • a For archive, keeps permissions, type stamps, etc.
  • v for verbose
  • e ssh , use over ssh
  • z for compression, if you want that. It won't try to re-compress archive (zip) files.

rsync generally comes with Linux distributions. It also meets your requirement of not transferring things that have not changed.

2
  • 2
    +1 for rsync. Here are a few useful rsync flags: when you are running rsync interactively (mostly during testing) use the --progress flag. Some informative statistics can be gathered by using the --stats flag. Also, if you dont want rsync to hog all of your bandwidth you can limit its download rate by using --bwlimit=KBPS KBytes per second. I also find it useful to use the -e parameter when I have to use a nonstandard ssh port like this -e" ssh -p 10222" Commented Oct 27, 2009 at 15:54
  • Mention of the -e flag when non-standard ports are being used also definitely comes in handy. :)
    – joebert
    Commented Oct 27, 2009 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .