Those who have done it know moving WordPress sites from one host to another is a huge pain in the butt. I’m currently going through a migration of sites from WiredTree to Dreamhost. My good friend, Andrew Mattie (who works at Zillow), completed the migration of the Oh Hey World travel blog and was kind enough to put together a step by step (for my other friend who is migrating the rest of my ESM Exec Designs sites) outlining how to move an entire WordPress site using a Shell account. I’ll summarize his steps and take out some of the steps & information specific to ESM.

First, several caveats. It’s difficult to lay out a hard and fast set of rules because there are quite a few factors that go into it. Moving sites via shell is not necessarily the “best” way as that’s pretty subjective. It’s just Andrew’s personal experience that Shell is the easiest in terms of time spent, fastest in terms of db and file transfer time, and the most thorough. The following steps certainly require a certain level of technical understanding and know how.

1. Create a site-specific SSH-enabled user in the Dreamhost control panel. Make sure you check the “use extra security” checkbox. Don’t share users between sites. Let Dreamhost generate the password.

2. Create a site, or using an existing site if it’s already listed there, and associate the site with the newly created user. You can put the content in the “public” folder, but you can put it wherever you’d like.

3. Create a db user / db in the control panel. If there’s an existing one, delete it and recreate it to ensure you’re working off an empty copy and a clean user where the password hasn’t been compromised.

4. Open a SSH session (#1) for that new user.

  1. Run ssh-keygen. Don’t enter a password when it asks.
  2. After generation, copy the output from ~/.ssh/id_rsa.pub into your clipboard.

5. Open a SSH session (#2) to wired tree server using the root login and password. Add the public SSH key to .ssh/authorized_keys to prevent having to save / remember the password.

  1. cd to the user’s home dir.
  2. Create the .ssh dir that folder if it doesn’t already exist. Change the owner / group of that dir to that of the user (since it’ll be root otherwise). Change the perms to 700.
  3. Create / edit the .ssh/authorized_keys dir. Paste the key from session #1, point 3.2 into that file. You’ll now be able to easily do server-to-server transfers.
  4. Put the following code into a .maintenance file in the root dir of the blog: <?php $upgrading = time(); ?> That’ll prevent new comments / edits / uploads from happening while you move the site.
  5. Call mysqldump with the db name / user / pass that’s in the wp-config.php file and echo it to a SQL file. The command will look something like this: mysqldump -uUSER -pPASSWORD DB_NAME > blog.sql

6. Back to SSH session #1

  1. Call “scp USER_NAME@[IP Address]:. .” to copy all files from the ESM server to the Dreamhost server. You won’t need a password or anything because you already took care of that with the SSH step.
  2. Restore the db with the mysql command. It’ll look something like this: mysql -uUSER -pPASS -hDREAMHOST_DB_HOST DB_NAME < blog.sql
  3. Update the wp-config.php w/ the new Dreamhost db info

7. Update your hosts file to put the Dreamhost IP directly to the new host so that you can test things out without it affecting others.

8. Upgrade WP and upgrade all plugins.

9. Install the Exploit Scanner plugin, run it, and look for anything unusual. Maybe the best thing to do if you’ve never done this before would be to just manually inspect each file that sets off an alarm and look for hackish-looking comments or long strings of indecipherable characters.

10. Migrate the DNS back, making sure to copy all DNS records.

The steps outlined above can be completed in about 15 min — creating everything in Dreamhost, prepping the site, waiting for the transfers, and then finish up and double check.

Best of luck with your site transfers!