Migrating your websites to the (gs) Grid-Service
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 (gs) Grid-Service. This document is by no means comprehensive, but it should cover the basics to get you on your way.
Moving your sites to (mt) Media Temple involves a few simple but important steps:
- Back up all website content, databases, and emails from your current host.
- Upload files and import your databases to your new hosting service at (mt) and re-create any email accounts.
- Update database connection strings and system paths to match the environment.
- Test the site using your Access Domain.
- Switch your Name Servers.
- 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. Throughout this guide there will be basic instructions and some more advanced ones for power users.
Moving your site to the (gs) Grid-Service.
1. Back up
Website Content
Log in to 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. You can also use SCP 1 to transfer files from your old host directly to your (gs). This guide assumes that you have a familiarity with using FTP.
Power Users: We will show an example on how to use SCP to copy directly from your old server to the new one you have here. 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). Please note that the document root for your (gs) Grid-Service will always be called html and nested under a domain folder.
scp -r * mt-example.com@mt-example.com:/home/#####/domains/mt-example.com/html/
This should transfer all of the files directly to your (gs) from the old host.
Databases
If you are moving over a site that has a database we will need to make sure we move that database over as well. There are a variety of ways to do this. We will focus on some simple examples using phpMyAdmin and using the shell. Full details.
Point-and-click backup using phpMyAdmin
- Log into your old host's phpMyAdmin panel and click on your database on the left hand side.
- Now that your database is selected click on the "Export" tab at the top.
- Please make sure you have selected the appropriate options in the screenshot below.
- Save the file, making sure to select "zipped" under "Compression". This will greatly reduce the size of your database file.
Power Users: A MySQL dump can be performed using SSH 2
Using SSH, log in to your old host. Using the mysqldump command we will create a backup of your database and then transfer it using SCP to your (gs) Grid-Service. 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 mt-example.com@mt-example.com:/home/#####/data/
2. Upload & Re-create
Now that you have a complete backup of your site files and database we need to move them to your (gs) Grid-Service. If you haven't already done so please take some time to review the Server Guide located inside the AccountCenter to become familiar with your account details before continuing.
Website Content
- Make sure you have created the new site using our KB article. Once this is complete we will have a place to put the content.
- 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/#####/domains/mt-example.com/html/. Place all your content here.
- 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. For the purposes of this guide you should be using MySQL, not PostgreSQL. After you've created your database, proceed with the next steps.
Importing via phpMyAdmin (under 10MB only)
- Click on the admin button to right of your new database in the Manage Databases section of the AC to import your backup file.
- From the column on the left select the database that you want to restore to.
- 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.
- 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."
Power Users: Importing via command-line
Log in to your (gs) Grid-Service using SSH and cd to your data directory. This is where we transferred our backup to earlier.
First we establish the connection:
ssh mt-example.com@mt-example.com Then we change directories:
cd data Now we will import your older data into your new database:
mysql -udb##### -p -hinternal-db.s#####.gridserver.com db#####_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 this KB article for details.
3. Site Updates
A Word About Site Paths and Previews
Most times 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 `db#####_dbname`.`wp_options` SET `option_value` = 'http://s#####.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 `db#####_dbname`.`wp_options` SET `option_value` = 'http://mt-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. 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.
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 (gs) is:// ** MySQL settings ** //
define('DB_NAME', 'db#####_dbname'); // The name of the database
define('DB_USER', 'db#####'); // 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. 3
4. Test
Test using your Access Domain
Every (gs) includes a unique Access Domain which can be used to view your websites before you switch your DNS. It will look something like this:s#####.gridserver.com
##### is used as an example and would be replaced by the unique 'site number' of your (gs) Grid-Service. The site number is available in your AccountCenter and Service Activation Letter.
Some examples uses are:
Previewing your primary domain: http://s#####.gridserver.com
Previewing a sub-domain or alternate domain: http://sub.alt-example.com.s#####.gridserver.com
Power Users: 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 (gs). We have created this KB article which explains the process in detail.
5. 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 4 and set your nameserver records to NS1.MEDIATEMPLE.NET & NS2.MEDIATEMPLE.NET and then wait for about 24 hours. Your website should be serving from your new (gs) Grid-Service after waiting! More information about our DNS can be found here.
6. 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:
- SCP requires SSH access. Most modern hosts provide this, but check with your old hosting provider if you are unsure. [Snap Back]
- You will need to have shell access at your old host for this method. [Snap Back]
- To be clear, you can use either $_ENV{DATABASE_SERVER} or 'internal-db.s#####.gridserver.com' as your database hostname. It all depends on your preference. More information is available in your Server Guide section of the AccountCenter. [Snap Back]
- 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. See this article for details [Snap Back]
Revisions:
02-16-2009: Fixed error in add-drop-table command. thanks for the comment Adlina.
Fields marked with an asterisk(*) are required. Comment on this article