目錄表

Migrating your Simple Hosting instance to another data center

Migrating your web site from an instance hosted in one data center to an instance hosted in another data center involves a few simple steps that we will cover in this tutorial. In short, those steps are:

1. Export the source code and database(s) for your site
2. Create a new instance on the data center of your choice
3. Delete the vhost (virtual host) for your site on the old instance
4. Import the source code and database(s) to your new instance
5. Update your DNS zone file to point to the new instance

Please note that this process will involve your site being temporarily unavailable while the new DNS records linking your domain name to your instance propagate. One way to reduce your downtime is to lower the TTL of DNS records linked to your Simple Hosting instance.

If you use Gandi's DNS, we suggest referencing the following documentation for more information:

http://wiki.gandi.net/en/dns/zone/

Since migrating your site will involve some downtime, we strongly suggest migrating during a low-traffic time for your site.

Export your database

The very first step in migrating your site is to export your files and your database from your instance.

To export your database, you have a number of options. The first is to use the phpMyAdmin interface. Alternatively, you can use a MySQL command line when connected via your instance's SSH console.

Exporting with phpMyAdmin

Log in to phpMyAdmin.

(for more information, see http://wiki.gandi.net/en/simple/mysql )

Next, select the database to export in the column to the left, then click on the menu “Export” on the top of the page. In general this will be the database that pertains to whatever web site software you installed, for example, if you installed WordPress, the database will probably be called “wordpress”. Make a note of the name for restoring it later. Choose the “rapid” export method and leave the other options selected by default. Next, click on “Run” to download the file in .sql format to a local directory.

Exporting with a MySQL command line

Connect to your instance through your SSH console. You can use the following documentation for help:

http://wiki.gandi.net/en/simple/console

Start by navigating to the directory where you would like to store your database files once exported. You should make sure this directory is one for which you have read/write access, like your 'tmp' directory, using a command like this one:

$ cd /srv/data/tmp

Then, run a command like this one to export your database:

$ mysqldump -u root -p database_name > database_name.sql

(-p will prompt you for a password. By default, the root user has nopassword, so you can just hit enter if you did not set one up).

A '.sql' file corresponding to your database will then be created in the 'tmp' folder (or the directory of your choice) of your instance. You can then download this file via SFTP (See below).

Download your files

Once you have exported your database, you can download it and your site's other files to a folder on your local computer.

Downloading files via SFTP

In order to connect to your Simple Hosting instance via SFTP, you will need to set up an SFTP client of your choice, in the unlikely event you havent already done so.

You will need to use the following connection details:

This information can also be found by hovering over the “Login” link on the Simple Hosting instance management page.

Link to : http://wiki.gandi.net/en/simple/sftp#connecting_to_your_instance_using_an_sftp_client

You will need to download the contents of your htdocs folder ( /lamp0/web/vhosts/www.yourdomainname.com/htdocs/ ) as well as the .sql file exported in the previous step, located in your tmp folder ( /lamp0/tmp ) or from the directory to which you exported your database using the SSH console. If you used the phpMyAdmin method, the .sql file is already saved on your local disk.

Create a new instance

At this point, create your new Simple Hosting instance. If you do not remember how to do that, feel free to review the following article:

http://wiki.gandi.net/en/simple/create-instance

Remember, the goal is to change data centers, so make sure you are selecting the data center you want. This option is one of the first fields on the instance creation form.

You should also make sure to leave the “Website address” field blank on this form. You will be completing this in the next step.

Remove the old vhost

This operation will necessarily involve some downtime since your files online (not the backup you just made) will be removed from the live site. This step is necessary in order to free up your vhost so that you can use the same address on your new instance.

Go to your old instance's management page to remove your site's vhost.

In the “Sites” section, located in the middle of the page, you can remove the vhost by clicking the big black X to the right of the vhost name.

The contents of the vhost are then moved to the Trash folder of your instance, so in case you accidentally delete the wrong vhost or delete your vhost before exporting and downloading the data stored in it, you can still access those files in the directory '/lamp0/trash' of your instance (that's '/srv/data/trash' if you are connecting via SSH console) indefinitely.

If you plan to continue to use your old instance after your site is migrated, you may want to consider emptying your trash folder once the migration is complete so you can free up disk space on your instance.

Create the new vhost

Your vhost address should now be available again, so you can recreate your vhost, this time on your new instance. If you need a reminder on how to create a vhost, take a look at the following page:

http://wiki.gandi.net/en/simple/shs-dns_config#add_a_virtualhost_to_your_instance

You can also at this point update your DNS zone file of your domain name in order to point your domain to your new Simple Hosting instance:

http://wiki.gandi.net/en/simple/shs-dns_config#dns_zone_file_configuration

Import your files to your new instance

With your new vhost created on your new instance, you can now upload your site's files via SFTP. This involves connecting to the new instance, and uploading the files from your old instance to the new htdocs folder in the new vhost.

Note for Git users

If you deploy your application code via Git, we suggest adding a remote repository using the command “git remote”.

Deploy your code on your new instance using commands similar to the following (presuming you are already in the working directory of your local repository):

$ git init
$ git remote add new ssh+git://{login}@git.dc{0,1,2}.gpaas.net/{vhost}.git
$ git add htdocs
$ git commit htdocs
$ git push new master
$ ssh {login}@git.dc{0,1,2}.gpaas.net 'deploy {vhost}.git'

Import your database

Similarly to how you exported your database, you can use phpMyAdmin or a MySQL command line to import your database.

Importing with phpMyAdmin

Access your phpMyAdmin page from your Simple Hosting administration interface on the new instance. You can find further information on this page:

http://wiki.gandi.net/en/simple/mysql

Click on the menu “Database” located on the top of the page.

Click on “Create Database” and type the database name to create and populate. Make sure it is the same name as the one you exported earlier.

Next, select the database that you just created in the column on the left, then click on the “Import” option at the top of the page. Choose the .sql folder from your local directory using the “Browse” button. Finally, click “Run” to import the .sql folder.

Importing from a MySQL command line

First, upload the .sql file via SFTP to your 'tmp' directory of your new instance.

Connect via SSH console to your Simple Hosting instance. For assistance with that, please see the following wiki page:

http://wiki.gandi.net/en/simple/console

Next, navigate to your 'tmp' directory:

$ cd /srv/data/tmp

Next, run the following commands:

$ mysql -u root -p
mysql> CREATE DATABASE database_name;
mysql> database_name < database_name.sql

Remove the old instance

Now that the migration is completed, you can remove your old instance.

If your instance was on an annual commitment, you can contact our Customer Care team in order to remove the commitment on it. You can then remove the instance from your Gandi account and you will be reimbursed pro-rata for the time remaining on your instance in your prepaid account.

Migrate your site with Gandi's website migration service

If you would like to migrate your website to a new Simple Hosting instance, but are not sure that you have the necessary know-how to do this, you can now use our website migration service (in beta testing).

We are currently providing this service via a third-party partner at the price of $65 (€50, or £45) excl. VAT, and only if it meets certain criteria. For more on this, and complete instructions, please visit our blog at:

http://www.gandibar.net/post/2012/10/08/Want-us-to-move-your-website-for-you