Move Fast and Break Things

Professionally Migrating WordPress

What I’m about to cover is centered around taking a clean, working WordPress installation and moving it. That could be to another server, another domain, or bringing it down to setup a local development environment.

A couple years ago I wrote an article (since retired it) on professionally moving WordPress. It involved dumping the database, bundling up the files, moving the files, importing the database and finally using some tools to clean up the entire process.

The process is still the same but much easier.

Get the Old Website

All WordPress websites are broken down into two parts. Databases and files. For the files, you should run something like this:

You’ll of course want to do that from within your website’s root directory.

For the database you have a couple options. The first one is the old school way:

That will ask you for a password and you will then have a text file containing your database. You can compress that and download it if you want.

The new fun way is if you have access to WP-CLI — if you don’t and want to install it, have at it, I cannot live without it these days:

If you do that from the root of your WordPress install it will read your wp-config.php file and do all the work for you.

Moving Everything

Download the tar-ball and the database file, transport those to your new location.

Unpack your files using something like this, do this in the folder you want your WordPress install to live:

Want to import your database? Update your wp-config.php to fit the new database location. Do this:

After that you may need to fix your domains within your database. Maybe you switched to a local development environment. The old domain was mywebsite.tld and the new one is mywebsite.sandbox — to fix that you should do this:

You may need to also consider adding subdomains or protocols like HTTPs in multiple statements if need be. That is a fantastic tool for searching and replacing values through all parts of WordPress database files. Including serialized data.

This is a very important process. Many 3rd party themes (and sometimes our custom themes) store the full url in serialized data and doing a simple search and replace of the data will break the site. You will lose any customizations done to the theme unless you follow the following steps.

Additionally, you may want to update your file permissions, this is what I typically do on most installs:

Now, lastly, if you moved this website and no one gave you an Administration account … because that happens quite often … you can make your own 😀

Do this:

Or you can hijack an account:

In conclusion, professionally moving a WordPress website is extremely easy. Hahahaha

No seriously, it’s not that hard. The difference between a professional and an amateur is motivation and consistency. You should aspire to consistently work with, transport, maintain and build Websites to the point where things like this are so basic that the quality of what you’ve just done would never come into question.

 

Leave a Reply