[Hacking WordPress]: How To Clone And Migrate Your WordPress Blog To New Server

wordpress logoIn the event that you need to migrate your current WordPress blog to a new server, or a new URL, the last thing that you want to do is to reinstall WordPress on your new server and reconfigure the setting all over again.

While you can use the export/import function under the ‘Manage‘ menu to migrate your database over, it is definitely not the best and ideal solution, especially if you have a huge database. In addition, if any of your plugins created their own databases, they aren’t going to be migrated by the export/import function.

To migrate your WordPress blog, the best and the easiest way is to clone it and plug it into the new server. Since WordPress is a database driven platform where all its configuration settings are kept in the database, we can achieve a cloning effect simply by backing up all its database tables (including those created by the plugins) and dump it into the new server database. There is no need for reinstallation or reconfiguration.

Here’s how you can clone and migrate your WordPress blog to a new server in 10 steps:

  1. Download the wp-db-backup plugin.
  2. Upload to your existing server and activate it via the ‘Plugins‘ menu.
  3. Go to the ‘Manage‘ -> ‘Backup‘ menu. Select all the tables (including those tables created by the plugins) and click the Backup button to download the gzip file to your computer.
  4. In your computer, extract the gzip backup file. You should now have a sql file.
  5. Open the sql file with a text editor. Search for the line
    INSERT INTO `wp_options` VALUES (1, 0, 'siteurl'

    You should see something of this format:

    INSERT INTO `wp_options` VALUES (1, 0, 'siteurl', 'http://www.your-old-url.com', 'yes')

    Replace the URL with your new server URL

    Next, search for the line

    INSERT INTO `wp_options` VALUES (39, 0, 'home',</code>

    You should see

    INSERT INTO `wp_options` VALUES (39, 0, 'home', 'http://www.your-old-url.com', 'yes')

    Replace the url with your new URL. Save and exit.

  6. Using a FTP program, download the whole WordPress folder from your current server to your computer. Keep the folder structure intact, especially the wp-content folder.
  7. Log in to the PhpMyAdmin in the new server (here is the instruction to access your PhpMyAdmin)
  8. Create a new database for your wordpress and import the sql file to the database
  9. Change the database configuration in the wp-config file in the WordPress folder that you have downloaded
  10. Upload the whole WordPress folder to the new server.

Done. You can now proceed to your wp-login page at the new server and login with the same username and password. All the configuration and settings will be the same as before.

If your WordPress database (the sql file you have created) is more than 2MB, the above method might not work since PhpMyAdmin only allows a maximum of 2MB file import.

To overcome this, you can use bigdump to dump the sql file to your new database.

The instructions below are no longer required.

  1. Download the bigdump file.
  2. Unzip the file.
  3. Open up config.php and change the database configuration.
  4. Copy and paste the sql file into the folder.
  5. Upload the ‘restore‘ folder to your new web URL
  6. On your browser, navigate to the url http://your-new-web-url.com/restore/bigdump.php
  7. Click on the “Start import” to import the sql file to the database
  8. Once completed, upload the whole WordPress folder to your new web server.

Done.

Update: for GoDaddy, ‘localhost’ will not work. But any user can access their account, access the control panel for hosting products and then see SQL databases. When in edit mode, the page will display the hosting path – this worked. – Mike Chung.

Thanks to Mike Chung for the tips.