Code Snippets

Use Rsync to to merge code differences

Sync websites that are on two separate servers using Rsync! Rsync finds files that need to be transferred using a "quick check" algorithm that looks for files that have changed in size or in last-modified time. Install rsync you can use the following commands. For more information visit our blog post about this topic.

sudo apt-get install rsync

or

yum install rsync

Once Rsync is installed. You can type rsync -man to see all the options available to it. Here is an example of Rsync:

rsync -r -v username@servername.com:/var/www/vhosts/site1/ /var/www/vhosts/site2

This example will merge the code from site1 on the remote server to site2 on my local. Using the -v specifies verbose and -r is recursive.

rsync -r -v --exclude “sites/default/files” username@servername.com:/var/www/vhosts/site1/ /var/www/vhosts/site2

This example will merge the code from site1 to site2 but will also exclude the directory “sites/default/files”. This is handy if a production environment is loaded with gigs of image files you don’t need. For more information on rsync, check “man rsync” or go to http://linux.die.net/man/1/rsync If you have any questions, feel free to ask.

Resource Tags: