Wednesday, August 25, 2010

How to recursively copy files from one server to another server?


I usually choose rsync linux command to copy the file and this is much more faster than any other method. It'll take few minutes though the size is in GB.

Here are the exact commands :

from_destination _server#]rsync -ravz -e ssh root@source_server_IP:/home/user/public_html/waiting4u /home/nomore/public_html

/home/user/public_html/waiting4u : Directory on source server.
/home/nomore/public_html : Directory on destination server.

r = recursive - means it copies directories and sub directories
v = verbose - means that it prints on the screen what is being copied
a = archive - means that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer
z = compress - compress file data

Special Note :

# rsync -r /waiting4u/ /Volumes/Backup/waiting4u/
The above example will copy the content of waiting4u to /Volumes/Backup/waiting4u/

# rsync -r /waiting4u /Volumes/Backup/waiting4u
The above example will copy the folder waiting4u and its content to /Volumes/Backup/waiting4u (it will create the folder: waiting4u).

If the server is using customized port then use following command :

from_destiny_server#]rsync -ravz --rsh='ssh -p5981' root@source_server_IP:/home/waiting4u/cpmove-waiting4u.tar.gz /home/cs1322gt/backup

-p5981 : ssh port of the source server.
--rsh='ssh -p5981' : To use the command "ssh -p5981"

Note : Alternatively you can also use scp command like :

from_source_server#]scp -P 5981 .ssh/ user@source_server_ip:/home/user/.ssh/authorized_keys

5981 : SSH port of source since scp works using ssh.
user@source_server_ip:/home/user/.ssh/authorized_keys : Location on destination server.

You can check the manual of both commands.

Try :)

No comments:

Post a Comment