Secure Copy (scp) Files from Old Host to New Host

While moving your site from old host to a new host, you have to transfer files from old host to new host as well as transfer database from old host to new host. Simply executing a copy command is not safe. While transmission using copy command the data may be compromised in the middle. So a better way is to execute secure copy command i.e. scp command.

We have already wrote how to Export and Import Database in a Hosting account.

Now you move your database file from old host to new host securely by executing the following command in your new host.

sudo scp -v -r admin@123.456.78.90:/admin/dbname.sql /home/admin/

Here, 123.456.78.90 is the IP address of your old host.
admin is the username.

If you have changed the default SSH key of your old host then you need to mention the port number also.

sudo scp -P 2345 -v admin@123.456.78.90:/admin/dbname.sql /home/admin/

Here, 2345 is the port number of your old host.

Executing the above commands you have successfully transferred database from one place to another. Similarly, you need to transfer other files also e.g. if you are running a wordpress site then you need to transfer all files including themes, plugins, uploaded media etc.

scp -v -r admin@123.456.78.90:/var/www/html/* /var/www/html/

If port number has been changed, then execute the following command

scp -P 2345 -v admin@123.456.78.90:/var/www/html/* /var/www/html/

Leave a Reply

Your email address will not be published.