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
cat id_rsa.pub

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/ root@destination.com:/var/www/

# Push from origin host to destination host, deleting files not on origin:
rsync -zaP --delete /var/www/ root@destination.com:/var/www/

# Pull from destination host from origin host
rsync root@destination.com:/var/www/ /var/www/

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

Leave a Reply

Your email address will not be published.

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