Copying a Remote folder using SCP

SCP (Secure Copy) is an excellent method of copying folders across different servers; it makes server moves a breeze.

To use SCP, log into the server you want to copy the files TO, and move to the folder in which you’d like the files and folders  to appear.

The SCP command itself is as follows;

scp -r username@servername:sourcefolder targetfolder

In this example, we will copy the folder public_html and its contents from a remote server to the server we are logged into.

Details you will need;

Remote Username: arthur
Remote Servername: 123.123.123.123 (you can use IP address or the domain name)
Remote Folder: /var/www/vhosts/testsite/httpdocs

On our local server, log in and move to the folder you wish to copy the files into, and issue the following command;

scp -r -c blowfish arthur@123.123.123.123:/var/www/vhosts/testsite/httpdocs/* /home/newtestsite/public_html

This will put the contents of httpdocs and all it’s subfolders into the folder public_html on the new server. Permissions on the new files and folders will be inherited from the user you have logged into the local machine as.

About Peter Connolly

Pete Connolly is a lead developer at TechMediaNetwork, and also Technical Director at KP Direction LLC. An experienced IT Manager and PHP developer, Peter is currently leading a great team of developers managing http://space.com and http://livescience.com, developing on the Ruby on Rails platform. More..