Skip to content

Instantly share code, notes, and snippets.

@ljaraque
Created June 25, 2018 01:42
Show Gist options
  • Save ljaraque/a1b49728fab04eca20042996740749a7 to your computer and use it in GitHub Desktop.
Save ljaraque/a1b49728fab04eca20042996740749a7 to your computer and use it in GitHub Desktop.
RSYNC for auto incremental remote backups

Incremental file unidirectional sync with Rsync via SSH Without Password

Reference: http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/

1. Installation of Rsync.

$ sudo apt-get install rsync

2. ssh-keygen generates keys.

Setup ssh so that it doesn’t ask for password when performing ssh. Use ssh-keygen on local machine to generate public and private keys.

$ ssh-keygen When prompted, do not input any password, just press Enter.

The file ~/.ssh/id_rsa will be created. This is the identity to be used by the local machine to communicate to remote. (If this file is created as user1, you have to copy it in .ssh/ directory of root to also enable connections without password as a root.
The file ~/.ssh/id_rsa.pub also generated by the previous procedure, will have to be copied to the remote machine.

3. Copy of Public Key to remote machine.

$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_machine

####3. Running rsync for syncing files from local to remote machine.
Note This procedure is unidirectional. For bidirectional sync please check Unison.
Reference: https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps
$ rsync -azP /pat/to/source/folder/ user@destination_machine:/path/to/folder/
This command will check the diff between source and destination files and change the remote version to the most updated version on the local machine. This is done only sending the incremental part, and compressing it if the z option is used as in the present example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment