Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
RSYNC for auto incremental remote backups

Incremental file unidirectional sync with Rsync via 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/ 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/ 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.
$ 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
You can’t perform that action at this time.