Setup Rsync between servers

rsync is a utility for efficiently transferring and synchronizing files across computer systems

Follow this post to setup public/private key to be used in rsync.
Just a quick note for my own quick reference

1. Generate Key on origin host

ssh-keygen -f ~/.ssh/id_rsa -P ""
chmod 0700 ~/.ssh/id_rsa

2. Allow Key on destination host

# Paste public copied above
vim ~/.ssh/authorized_keys

3. Run rsync

# Push from origin host to destination host:
rsync -zaP /var/www/ [email protected]:/var/www/

# Push from origin host to destination host, deleting files not on origin:
rsync -zaP --delete /var/www/ [email protected]:/var/www/

# Pull from destination host from origin host
rsync [email protected]:/var/www/ /var/www/

# Remember the tailing slash, otherwise directory level will be wrong

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.