Migrating your websites to the Grid


Browse by products and services

  • Applies to: Grid
    • Difficulty: Medium
    • Time Needed: 60
    • Tools Required: SSH, FTP Client, DNS Control

Overview

Whether you have a site with just static html pages or a dynamic database-driven one, this migration guide should help you get started with your new Grid. This document is by no means comprehensive, but it should cover the basics to get you on your way.

Moving your site to the Grid

Moving your sites to (mt) Media Temple involves a few simple but important steps:

  1. Backup all website content, databases, and emails from your current host.
  2. Upload files and import your databases to your new hosting service at (mt) and re-create any email accounts.
  3. Update database connection strings and system paths to match the environment.
  4. Test the site using your Access Domain.
  5. Switch your nameservers.
  6. Verify that your visitors are successfully seeing your site on your new server.

Below, we will go into more detail. This guide assumes you still have access to your old host. We will use and refer to elements of WordPress as the example for moving a site with dynamic content. Also, throughout this guide there will be both basic and advanced instructions.

move_to_mt_560x240

CloudTech Can Help!
(mt) Media Temple offers assisted site migrations via CloudTech, our premium services division. To learn more, please click here.


Backup

Website Content

Log into your old host and download all the files for your domain to your local computer. The most popular way to do this is via FTP. This guide assumes that you have a familiarity with using FTP. To learn more, please read: Using FTP and SFTP.

Alternatively, you can use SSH to transfer files from your old host directly to your Grid. For information, please read: Connecting via SSH to your server. We will show an example on how to use the command scp to copy directly from your old server to your Grid.

Using SSH on your old host, run this command from the document root. This folder might be called httpdocs, html, public_html, or other variants. Check with your old host if you are unsure. Please note that the document root for your Grid will always be called html and nested under a domain folder.


scp -r * example.com@example.com:/home/00000/domains/example.com/html/

This will transfer all of the files directly to your Grid from the old host.

TIP:

If you have not yet transferred the nameservers to (mt) Media Temple, you will need to replace the @example.com with your access domain (s00000.gridserver.com). So, in this case, the command would be:


scp -r * example.com@s00000.gridserver.com:/home/00000/domains/example.com/html/

Databases

If you are moving a site that has a database, we will need to make sure we move that database as well. There are a variety of ways to do this. Two examples follow: 1) Using phpMyAdmin and 2) using the command line.

Point-and-click backup using phpMyAdmin

  1. Log into your old host's phpMyAdmin panel and click on your database on the left-hand side.
  2. Now that your database is selected, click on the "Export" tab at the top.
  3. Please make sure you have selected the appropriate options in the screenshot below.

    phpmyadmin

  4. Save the file, making sure to select "zipped" under "Compression." This will greatly reduce the size of your database file.

Via SSH

Using SSH, log into your old host. The mysqldump command we will create a backup of your database and then transfer it using scp to your Grid. Please consult your old host if you do not know your login details. Replace DATE with today's date, if you like.

First we create the dump:


mysqldump --add-drop-table -uusername -ppassword databasename > mysqlbackup.DATE.sql

Then we transfer it over:


scp mysqlbackup.DATE.sql example.com@example.com:/home/00000/data/

Upload & Re-create

Now that you have a complete backup of your site files and database, we need to move them to your Grid. If you haven't already done so, please take some time to review the Server Guide located inside the AccountCenter and familiarize yourself with your account details before continuing.

Website Content

  1. Make sure you have already added the site to your Grid. Once this is complete, we will have a place to put the content. More info is available here: Adding a domain or subdomain.
  2. If you did not use scp to move your files over in the advanced step above, please upload your files using FTP to this new domain. Your web path should be /home/00000/domains/example.com/html/. Place all your content here.
  3. At this point, you should be able to see your content using your Access Domain. This makes it easy to "preview" your site before switching over your DNS which we will get to shortly.

Databases

First, we need to create the new database. After you've created your database, proceed with the next steps.

Importing via phpMyAdmin (under 10MB only)

  1. Click on the admin button to right of your new database in the Manage Databases section of the AccountCenter to import your backup file.
  2. From the column on the left, select the database that you just created.
  3. Click on Import from the top set of tabs and click on Browse to upload your file. Make sure you have unzipped your file locally first. You want to import a *.sql file, not a *.zip file.
  4. If successful, you should receive a message similar to this: "Your SQL-query has been executed successfully : The content of your file has been inserted."

Importing via command line

Log into your Grid using SSH and cd to your data directory. This is where we transferred our backup to earlier.

First we establish the connection:


ssh example.com@example.com

Then we change directories:


cd data

Now, we will import your older data into your new database:


mysql -udb00000 -p -hinternal-db.s00000.gridserver.com db00000_dbname < mysqlbackup.DATE.sql

Re-Create your email accounts

This is fairly simple to do and requires only logging in to the AccountCenter and going to the "Email Users" section. See Creating a POP/IMAP email account for details.

Update Site Paths and Preview

Generally, you will not need to worry about updating site path references in your website code. There are some cases, however, where this can occur and make your website appear to be broken. The reason for this is every host has a different design and preference on their directory structure. Most modern applications and coding practices encourage using relative paths and variables, so this should not be a big concern.

One important thing to mention is that WordPress and many other apps do have a configuration setting for the domain name. If you try to preview your website (we'll cover how a bit further down) using your Access Domain, you may experience display problems. For this case and cases like it, you'd need to change a setting which makes your access domain the site URL.

This can be accomplished by running the following command in the SQL tab of the phpMyAdmin on your service here:


UPDATE `db00000_dbname`.`wp_options` SET `option_value` = 'http://s00000.gridserver.com' WHERE `wp_options`.`option_id` =1 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = 'siteurl' LIMIT 1 ;

To revert back to your actual domain for the switch, this will do the job:


UPDATE `db00000_dbname`.`wp_options` SET `option_value` = 'http://example.com' WHERE `wp_options`.`option_id` =1 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = 'siteurl' LIMIT 1 ;

You may need to do similar modifications for other apps. Always consult your software's documentation.

Database Connection Strings

Any website that utilizes a database needs to be able to make a connection to that database. When moving to a new host, it is important to know where your database connection strings are located so you can update them to work with your new environment. Popular CMS applications such as Joomla, WordPress, Magento, Gallery and many others tell you what file to edit in their software documentation.

If you want to find all files containing a database connection string, run this command from the domains directory:


grep -rl "localhost" *

This will search all plain-text files for the string "localhost" and give you a simple list to go through. The reason we're searching for that is because localhost is the hostname that the majority of hosts use, so you have a good chance of finding your config file if you look for that phrase. You can find your new database username, password, database name, and host address inside the Server Guide section of your AccountCenter.

An example of the correct setting for a Grid is:


// ** MySQL settings ** //
define('DB_NAME', 'db00000_dbname'); // The name of the database
define('DB_USER', 'db00000'); // Your MySQL username
define('DB_PASSWORD', 'tH15i5myP4SSW0rd'); // ...and password
define('DB_HOST', $_ENV{DATABASE_SERVER}); // 99% chance you won't need to change this value

The $_ENV{DATABASE_SERVER} environment variable may be used instead of specifying your database hostname.

You should also read System Paths.

Test using your access domain

Every Grid includes a unique access domain which can be used to view your websites before you switch your DNS. It will look something like this:


s00000.gridserver.com

00000 is used as an example and would be replaced by the unique site number of your Grid. The site number is available in your AccountCenter and Service Activation Letter.

Some examples uses are:

  • Previewing your primary domain: http://s00000.gridserver.com
  • Previewing a sub-domain or alternate domain: http://sub.alt-example.com.s00000.gridserver.com

Also, there is a more advanced method of previewing your sites before switching DNS which involves making a configuration change on your local computer to resolve your domain to your Grid. We have created "How can I test/preview my website before switching DNS?" which explains the process in detail.

DNS Switch

Have you:

  • Moved your website content
  • Moved your databases
  • Re-created your email users
  • Previewed your site

If you think you're ready to go, now is the time to switch your DNS! Go to your registrar and set your nameserver records to NS1.MEDIATEMPLE.NET & NS2.MEDIATEMPLE.NET and then wait for about 24-48 hours. Your website should be serving from your new Grid after waiting! More information about our DNS (mt) Media Temple's DNS/Nameserver information.

Verify

Let your users know you've moved over to (mt) Media Temple! This will not only show that you communicate with your visitors, but also serves as a great way to have more than yourself on the lookout for any odd side-effects of the entire moving process. Make sure all of your links work, that none of your email addresses are bouncing, and that nothing seems out of place.

Once you're 100% sure that your sites moved over properly, you can close out your old hosting service and enjoy your new home at (mt) Media Temple!

Notes

  1. SCP requires SSH access. Most modern hosts provide this, but check with your old hosting provider if you are unsure.
  2. You will need to have shell access at your old host for this method.
  3. To be clear, you can use either $_ENV{DATABASE_SERVER} or 'internal-db.s00000.gridserver.com' as your database hostname. It all depends on your preference. More information is available in the Server Guide section of the AccountCenter.
  4. If you registered your domain with (mt) Media Temple, or if you transferred your domain here, you can change your nameserver settings from within your AccountCenter.