Use SCP To Transfer Large/Many Files From Server To Server

Let’s begin and assume the following information:
Server OLD_HOST is our host where the original files are located.
Server NEW_HOST is where we need to copy files to.

[INDENT]1. Make sure on Server OLD_HOST you have enabled Shell access for the user account you are going to use.
Let’s say our files are in /home/marius/public_html/EXAMPLE.
In this case, make sure you enable user marius shell access.

2. Login SSH on Server NEW_HOST, login as root “su”, or as marius should work too so long as you stick the files in the same place.

3. Type the command:

screen

In case you have a transfer that will take a while, a screen process will make sure your transfer goes on if you get disconnected.

3.1. If you get disconnected, just connect back to the server and type:

screen -r

4. Type this command:
where xx.xx.xx.xx is the IP address of Server OLD_HOST

scp -rv [email]marius@xx.xx.xx.xx[/email]:/home/marius/public_html/EXAMPLE/ /home/marius/public_html/EXAMPLE/

notice there is a *SPACE* after …/EXAMPLE/ and /home/…
make sure the path /home/marius/public_html/EXAMPLE/ exists.

You will be prompted for the SSH password of marius at Server OLD_HOST. Enter this, and the copy process will start.

the -r option copies everything in the directory tree.
/home/marius/public_html/EXAMPLE/dir1/
/home/marius/public_html/EXAMPLE/dir2/
/home/marius/public_html/EXAMPLE/dir3/moredir1/
etc…..

the -v option is verbose, lets you see the transfer in action in your ssh terminal.

5. The screen started earlier, can be used to move the transfer in the background by pressing

Ctrl+A D

reattach to the screen using the command from 3.1[/INDENT]

The scp command is just like the cp command only it uses SSH to move data from one machine to another.

SCP manual here:
http://linux.about.com/od/commands/l/blcmdl1_scp.htm

Wayne Egerer

Leave a Reply