Rsync data migration between serversIf you need to upload the same pictures to a different directory on a server or copy files from server to a different server, there is a much easier method than duplicating your work. Simply use the Rsync command.

Wikepedia defines rsync as a software application for Unix systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. An important feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each di [level-premier-free]rection. rsync can copy or display directory contents and copy files, optionally using compression and recursion.

In daemon mode, rsync listens to the default TCP port of 873, serving files in the native rsync protocol. rsync can also be used to synchronize local directories, or via a remote shell such as RSH or SSH. In the latter case, the rsync client executable must be installed on both the local and the remote host.

To transfer files on the same server between websites:

From ssh, execute this after populating with the appropriate information of where your first site is located, followed by your second site location, or where you want to copy (sync) the files. This is all on one line, don’t break it like it shows below.

rsync -av /var/www/vhosts/WEBSITENAME/httpdocs_or_public_html/images/ /var/www/vhosts/WEBSITENAME/httpdocs_or_public_html/images/

To transfer files from one server to another:

This is a little trickier as it requires input of password, that the originating server allows this command, etc.

rsync -e ssh -avz username@SERVERIPADDRESS:/home/WEBSITENAME/public_html/catalog/images/thumbs /home/WEBSITENAME/public_html/catalog/images/thumbs

if asked for password, enter and hit enter.

ERROR NOTE:  If you get error is ssh clean… that means shell access needs to be enabled via whm, list accounts, click user.

ERROR NOTE:  We had a hardware firewall on one server and APF on the other firewall we were trying to bring images to.We kept getting error in rsync protocol data stream (code 12) errors and found out that if you disable apf at ssh it works fine.


Leave a Reply

Your email address will not be published.