How to Move Websites Using SSH

I often find myself backing up and moving websites across servers including my localhost.

To help you complete the same process, I've posted these simple commands to go someway to helping you understand how to do this. There are always different ways at tackling these problems but this I believe is the clearest, although not necessarily the most secure.

PRELUDE: I'm moving a site from one LIVE server, to another live website. The LIVE folder on the first machine is called httpdocs/, and the LIVE folder on my new server is called html/

Go up on level from your live folder that you wish to move to the new server. Backup this folder:

tar czvf backup-2017-05-25.tar.gz httpdocs/ 

This creates a single file that has backed up your entire directory

You now want to copy this file into an accessible place so you can grab it from your live server:

cp backup-2017-05-25.tar.gz httpdocs/

This file is now accessible from

Login to the new server and copy the file from the old server to the new one using wget:


Now delete the publicly accessible backup file from the original server by logging back into it and running this command:

rm backup-2017-05-25.tar.gz

Once you've checked that this file isn't available anymore return to the new server and decompress you backup file. Go to the top level of the directory where you can see html/ and decompress the file there:

tar -xzf backup-2017-05-25.tar.gz

Now that's decompressed you should have 2 directories - html/ and httpdocs/. If necessary, go into the new httpdocs directory and update the owner and group of all the directories:

chown -R *

Whilst in the httpdocs directory, run this command to copy across the decompressed files to their correct and live location:

cp -aRv * ../html/

Finally check that the files have moved across correctly and that the permissions are correct. I'll update this rough guide to include database backups soon too.