Need Nightly rsync script from older Linux server to Ubuntu

Need Nightly rsync script from older Linux server to Ubuntu

OK, I apologize for not figuring this out on my own through the dozens of online sites and questions here as well...but I'm in a time crunch and don't want to break anything.

I need to backup a folder and all subfolders and files from one Linux server (Gentoo) to a Ubuntu box on the same network, preferably using rsync.

Here's what I need:

  1. Can someone supply me the steps to make sure the Ubuntu target box is ready to receive the rsync (permissions, etc.)?
  2. The rsync script itself. All I need it to do is sync to the target nightly everything in the source folder/subfolders/files with permissions, etc. Ideal would be 5 copies called Monday/Tuesday/Wednesday/Thursday/Friday but I'm willing to live with a single copy that gets overwritten nightly (as long as the source doesn't change)

Thanks!

答案1

On the Gentoo box, do an "ssh-keygen" to generate SSH keys for the account running the cron. Make sure you don't set a passphrase for the private key.

On the Ubuntu box, put the public key from the Gentoo box into the target account's .ssh/authorized_keys file.

Assuming /path/to/files on the Gentoo box and /path/to/backups/ on the Ubuntu, you can then do something like:

rsync -v -a /path/to/files/ ubuntubox:/path/to/backups/`date +%A`/

which should put the contents of /path/to/files/ into something like /path/to/backups/Thursday/ on the Ubuntu box.

I would use a "-n" option in rsync when testing, to not actually write stuff to the target.

相关内容