Copy Files Between Two Servers Using SSH
This morning I was tasked with migrating a site to a new server. Since both servers were on the same network and behind a firewall it seemed like the most efficient thing would bet to copy the files direction from one to the other. I was able to accomplish this using the following command.
scp -r /var/www/mysite.com user@host:var/www
SCP is a ‘Secure Copy’ between the two servers. I pass ‘-r’ because I want to do a recursive copy. Then I pass my SourceFile followed by my TargetFile.
Since my TargetFile was on the remove server I passed my user and host with the target path. If my source was on a remote server I would include my user and host with the source path.