Entity view (Content)

Using Rsync to merge code differences

By brandont
Oct. 17, 2011

I just wanted to point out something that I use very frequently that allows me to sync websites that are on two separate servers. 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. Its a fast and efficient way to merge two different code bases without having to use ftp or any diff program. Using Rsync is simple. First to install rsync you can use the following commands.

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 site 1 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.

Post Tags: