Move Website via SSH

From Site5Wiki

Jump to: navigation, search

Contents

How to move your website if both hosts offer SSH

If you need to move your website, and your former host offers SSH - you can do so easily and fairly quickly using SSH.

First you will need to log into SiteAdmin and enable SSH for your hosting plan on our servers:

https://backstage.site5.com/ >> SiteAdmin >> Advanced Tools >> Get Shell Access >> Enable

For this walk through, we used Putty: http://www.chiark.greenend.org.uk/~sgtatham/putty/

If you have a database

If you have a database(s), prior to creating your website file archive you will want to create a backup for each placing the dump files in your web root directory so it is also archived. Instructions on how to so so can be found here: Creating a Dump of your Database via SSH.

Note: The above tutorial assumes public_html is your web root, if your former host utilizes a different web root such as htdocs or www, please adjust accordingly.

Creating your Archive

The first step is to make your backups at the host you will be leaving. The first backup will be of your website files themselves. To do this you will SSH to your old host. If you do not know your username/password to SSH to your old host, you will need to contact them to retrieve this information.

Once you are logged in you will need to move to your web directory, typically: public_html, www, or htdocs directory (we will use public_html in the example):

cd public_html

You are now ready to make your tarball archive, at the prompt type:

tar -cpzf filename-date.tar.gz *

ie:

tar - cpzf mydomain-04-01-08.tar.gz *

This command will create a file in the name you chose within your public_html directory. The flags "cpzf" will create a tar file of all the files within public_html, preserving the permissions of the files, into a gz compressed tar file. Do not forget the trailing "*", as that states "all" and without it your archive will fail. Download this file so you have a local backup of your website (you should always maintain a local backup of our site in case there is an issue with your hosts backup!).

Please note, this archive will *NOT* include any databases, email or files outside of your web readable directory (such as .htpasswd files).

This command can also be used to create an archive of your website for you to download. For a listing of tar switches, please see Unix Man Pages: tar ()

Moving your files

Once your archive has been created you can then login to your hosting at Site5 via SSH and copy the file to our servers. To use 'wget', you will first need to email Technical Support requesting that you be added to the trusted users for SSH, please include in your email the following information:

  • Your account username
  • Your server name
  • State that you would like to be added to the trusted users group so you can use wget to transfer your site files.

Your IP address will be listed in your Welcome email as well as your FTP user/pass. SSH will utilize the same user/pass. If you do not have your welcome email with your IP handy, you can also view it on the home page of SiteAdmin.

Once you have logged in, you will need to switch to the directory you would like to place the archive (typically public_html):

cd public html

You will then transfer the file from your prior host:

wget http://web-access-to-old-site/mydomain-04-01-08.tar.gz

Where "web-access-to-old-site" is your former hosts IP address, your domain (if you have not yet updated your DNS to our servers), or their domain/~username - whatever method they provide for you to access your site when there is no DNS active to their servers.

Once your transfer is complete, you will then uncompress your archive:

tar -xzf mydomain-04-01-08.tar.gz

Congratulations! You just moved your site via SSH. Please check it either through your domain name (if your DNS is active to our servers) or through your hosting plans IP address.

The switches xzf in this command are extract, gzip, file.

If you also backed up your Database(s)

Please see Restoring your Database via SSH.


Basic SSH Commands

A listing of Some Of The Most Commonly Used SSH/Shell Commands

Personal tools