Migrate your instance to another datacenter

Migrating a site on a Simple Hosting instance to a Simple Hosting instance located in another datacenter can be done in a few steps:

  1. Backup the source code of your website(s) as well as the database(s),
  2. Create the new Simple Hosting instance in another datacenter,
  3. Remove the virtual host from the old instance and recreate it on the new instance,
  4. Upload the source code of the website(s) to the new instance and import the database(s),
  5. Edit the domain’s DNS records to point the website to the new instance.

This procedure will cause a service outage of a few hours due to the modification of the DNS records. In addition, it will be necessary to remove the virtual host on the existing instance before you can recreate it on your new instance. To reduce this downtime, you can reduce the TTL of the DNS records that are related to your Simple Hosting instance 24 hours prior to beginning this process.

Backup website files

You will need to download the website files and database of the virtual host of your instance using an sFTP client, such as FileZilla.

To connect to your SFTP Simple Hosting instance, you will need to know the following information:

  • Host: sftp.sdX.gpaas.net

  • Port: 22

  • User: Your unique identifier. A multi-digit number, provided in the confirmation email sent when creating your instance, also visible on the management page of your instance. Be careful, ** it’s not ** your Gandi username.

  • SFTP Password: The one you defined when creating your instance. If necessary, you can change this password from the Password Management section of your Simple Hosting instance.

    Note

    You can find the Host and User ID by navigating to the Sites section of your Simple Hosting instance, then click on the Site you wish to connect to and locate the sFTP section on its Sites page.

Export databases

To export your databases, several solutions are available to you. You can use a database management interface, such as phpMyAdmin, or the MySQL command line when connecting through the SSH console of your instance.

Example with phpMyAdmin

  1. Go to your Simple Hosting Control Panel to access phpMyAdmin,
  2. Then select the database to export in the left column, and click on the ‘Export’ menu at the top of the page,
  3. Choose the ‘Fast’ export method and leave the other option at their defaults,
  4. Finally, click ‘Run’ to download the ‘.sql’ format file to your local computer.

Example with the MySQL command-line

Login to the SSH console of your Simple Hosting instance.

Navigate to a directory where you have write permissions, such as /srv/data/tmp/, using the following command:

$ cd /srv/data/tmp

Then run the following command to export the database to a file:

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

An ‘.sql’ file corresponding to the database will then be created in the ‘tmp’ directory of your instance, and you will be able to download it via sFTP at the path /lamp0/tmp/.

Create the new instance

You can now create your new Simple Hosting instance.

Remember to select the desired datacenter location you want your website hosted from.

Delete the old virtual host

Note

This operation will result in a service interruption because the files on the site in production will be deleted. This step is necessary to release the virtual host so that is can be declared on your new instance.

  1. Go to the management interface of your instance to delete the relevant virtual host,
  2. In the section labeled ‘Sites’, select the vhost, and then click on the “Delete” button,
  3. The deleted virtual host files will be placed in the ‘trash’ directory, allowing you to restore the files in case of problems. To access the ‘trash’ directory via sFTP, navigate to the /lamp0/trash/ path. Via SSH console, use the /srv/data/trash/ path.

Also remember to delete the virtual host files from the trash directory when the migration is completed in order to free up space on your disk.

Create the new virtual host

The virtual host is now released, so you can recreate it on the new instance.

You can also configure your domain’s DNS records to point to website’s address the new Simple Hosting instance.

Upload your files to the new instance

With the virtual host created, you can now upload your files to the new instance via sFTP.

Note to Git users

If you deployed your application code via Git, you can add a new remote repository using the git remote command and then push/deploy the code to the new instance.

You will be able to deploy the code on your new instance using the following commands, assuming you are already in the working directory of your local repository:

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

Import databases

In the same way as the database export, you can use phpMyAdmin or the MySQL command-line to import your database(s).

Example with phpMyAdmin

  1. Go to your Simple Hosting Control Panel to access phpMyAdmin,
  2. Click on the ‘Databases’ menu at the top of the page,

3. Specify the name of the database into the ‘Create Database’ field, 4.Then select the database that has just been created in the left column, then click on the ‘Import’ menu at the top of the page, 5. Choose the ‘.sql’ file to import from your local computer with the ‘Browse’ button, 6. Finally, click ‘Run’ to import the ‘.sql’ file.

Example with the MySQL command-line

First, upload the ‘.sql’ file via sFTP into the tmp directory of your new instance.

Login via the SSH console, then navigate to the /srv/data/tmp/ directory.

$ cd /srv/data/tmp

Then run the following commands:

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

Deleting the old instance

The migration is now complete, so you can delete the old instance if you are no longer hosting any other websites on it. Your Gandi prepaid account will automatically receive a pro-rated reimbursement for the remaining time of the current subscription, which can be used for future Gandi purchases.

Migration Service

If you do not want to perform this migration on your own, we offer a migration service managed by a partner who will support these operations. If this offer interests you, we invite you to contact support for more information.