HOW TO: Backing up files with 1 line of code Print

  • 1

rsync -avz /my/folder/ user@SERVERIP:/home/user/my/folder

Yup, that's it. All you do is enter the above command on your source server and hit enter, you'll be prompted for your password and then the backup will begin!

Now of course this is far from ideal for an automated backup, for that you'll want to setup a secure RSA key and use this code:

rsync -avz -e "ssh -i /user/.ssh/id_rsa" /my/folder/ user@SERVERIP:/home/user/my/folder

Yeah, not much more than the first line, but this one doesn't ask for a password so you can set this up to run as a cron so you can sleep good at night.

Was this answer helpful?

« Back