The internal import and export tools in WordPress work pretty well…if the site you’re migrating is relatively small, doesn’t use a custom theme, and wasn’t built with any tricky coding. The internal tools worked for the bloggers that made up the biggest group of WordPress users in the platform’s early years, but migrating a modern site requires more advanced tools.
The WordPress ecosystem has evolved enormously over the last 20 years, and migration tools have evolved along with it. Today’s sites are often bigger and more complex than they were then. The built-in tools in WordPress are simply not extensive enough to easily migrate the entirety of one website’s data to another.
In this article, we’ll look at what the WordPress suite of export and import features can do, dig into what it can’t, and compare it to the capabilities of WP Migrate Lite, our free migration plugin. We’ll also discuss the even more advanced features available with WP Migrate Pro, including push and pull migrations.
Table of Contents
- Drawbacks of WordPress Export/Import
- Migrating With a Plugin
- Export Your Whole Site
- Import Directly to Local
- Scale Up With WP Migrate Pro
- Wrapping Up
Drawbacks of WordPress Export/Import
Head to the export page within your WordPress dashboard, and you’ll notice it’s quite limited in what it will allow you to export. You can export the whole database, or just “Posts”, “Pages”, or “Media”. Clicking on those last three will open a menu that offers you slightly more granularity in exactly which files to export, but not very much. “Media”, for example, only allows you to filter by inputting a range of dates.
The import tool is even more limited. It isn’t really a migration tool, but a way for bloggers to move posts and comments from another service to WordPress. Naturally, it will only import what the other service will export.
However, there are limits to what will be transferred even if you’re migrating from one WordPress site to another. For example, if you export your media library using the built-in tool, you don’t actually export the files. You’re exporting an XML file that contains links to your media files. The built-in importer will try to bring the files over, but it isn’t very good at it. It will certainly import the links, and as long as the links are publicly accessible those images will show up on your site. However, deleting the files from your old site will cause the image links to break on the new one.
If you’re relying on the built-in WordPress tools, you’ll probably need to import all of those files manually. This is one reason for the popularity of migration plugins.
Migrating With a Plugin
If you’re migrating your site to WP Engine, you can turn to the WP Engine Automated Migration plugin to migrate your site for you. Just give the plugin your WP Engine SFTP credentials, and it will do the rest.
It’s a great plugin, but it only works for migrating your site to a WP Engine server. For every other situation, there’s WP Migrate. This plugin comes in two versions: WP Migrate Lite, the free version that handles most of the common tasks involved in migrating your WordPress site, and WP Migrate Pro, which adds additional features such as push/pull migrations, CLI integration, and multisite tools.
Find and Replace During Database Migrations
As mentioned previously, WordPress will export your database, but you’re very limited in choosing which tables to export. WP Migrate Lite lets you choose which tables to migrate. This means you can elect to migrate (or backup) the entire database or just select tables.
If you’re just exporting the database, WP Migrate will give you a SQL dump file you can import directly into your new database. If you’re including other files, such as media, themes, or plugins, then WP Migrate will export a ZIP archive. The ZIP file includes both the database and any other files you’ve selected.
WP Migrate Lite allows you to find and replace content directly from the plugin’s interface. Once you’ve made your selections, you simply export the SQL and then import it into your new database using a tool like phpMyAdmin.
The Find & Replace function in WP Migrate is one of its strongest features. It gives you fine-tuned control over your migrations, but it can also be used at any time to gain insight into your database and make changes to your current site.
You can refine your search by restricting it to certain tables, certain post types, or both to really narrow the focus. The options for backing up your database are similar, allowing you to backup all tables, tables you select, or just the tables selected for the migration.
“Advanced Options” allows you to exclude temporary cached data, spam comments, and/or post revisions from your search. In addition, you can also replace your GUIDs. In most situations, you should not replace your GUIDs. We recommend checking this box only if you’re taking a site live for the first time.
Support for Serialized Data
WP Migrate’s Find & Replace feature also supports serialized data. Typically, a find and replace applied to data using PHP serialization will corrupt that serialization. WP Migrate avoids this by first unserializing your data, then identifying individual strings and replacing the matching content. WP Migrate then serializes the data again before placing it in your new database.
Export Your Whole Site
WP Migrate Lite can export your entire site, including themes, plugins, and all your media uploads. Everything required to recreate the site in a new environment is included in a downloadable ZIP file.
When we say everything, we mean everything. Just tick the checkboxes, and those files will be included in your ZIP. This includes WordPress core files, which is helpful in perfectly replicating the site in a new environment. The core files include
wp-config.php, so copying this over ensures any constants defined in the file remain the same throughout the migration. Including core files also means you don’t even need a copy of WordPress on the server you’re migrating to, whether local or remote.
The “Media Uploads”, “Themes”, and “Plugins” sections give you the same sort of fine-tuned control as the Find & Replace feature, but over the parts of the site not included in the database. You can export all your media, only the files created or modified since the last migration, or any files created or modified after a certain date.
In the case of plugins and themes, you have the choice of exporting all of them, just the active ones, or a custom selection. You can also easily exclude theme and plugin files by unchecking the boxes you don’t want to include.
Excluding Files With Gitignore Patterns
You can also exclude media, theme, and plugin files from your export by using gitignore patterns. Each line specifies a different pattern, with WP Migrate processing them in the order they appear.
Some patterns are included by default. These can be removed if you wish, but it’s more likely that you want to add some patterns. For example, say you want to exclude all of the custom style sheet files from the export. In that case, you would simply add
*.css to the existing list:
.DS_Store .git node_modules *.css
You can also insert patterns that only exclude files found in certain directories. To do so, you must include the pathname and additional
gitignore syntax. As usual, pathnames are indicated by a trailing slash.
Adding two consecutive asterisks to the pattern allows you to more closely control the directories that are searched. How the search is conducted depends on where they’re placed in relation to the trailing slash:
**/looks for matches in the named directory and everything directly under it.
/**matches everything inside, with infinite depth.
A single asterisk, however, serves as a wildcard. So if we wanted to exclude all the css files, but only in the
assets directory, we’d use this:
.DS_Store .git node_modules **/assets/**/*.css
You can also negate patterns by adding a
! at the start. This is very handy for when you want to exclude all files of a particular type, except those found in a certain directory:
.DS_Store .git node_modules *.css !**/assets/**/*.css
Import Directly to Local
Local by WP Engine is ranked among the best local development environments for WordPress by HubSpot, CodeinWP, WP Hive, Torque, and others. We wrote a glowing review of Local in early 2021, long before Delicious Brains was acquired by WP Engine.
Being part of the same company has allowed the WP Migrate and Local teams to work together on providing flawless integration. Check out Import a WordPress Site to Local for more details, but it’s essentially a two-step process:
- Export your site.
- Drag and drop the ZIP file directly into Local.
WP Migrate automatically generates a
wpmigrate-export.json file whenever you export a site. This file is included in the ZIP archive, and contains metadata such as the PHP and MySQL versions in use on the site. Local reads from
wpmigrate-export.json and attempts to automatically match those settings, giving you a site that’s as close as possible to the original. This allows you to experiment and develop new features in complete safety without compromising your live site.
Thanks to WP Migrate’s ability to migrate plugin files, the migrated copy of your site can also include a copy of WP Migrate! This adds an incredible capability for users of WP Migrate Pro: using its push/pull functions to make incremental changes to a live WordPress site.
Scale Up With WP Migrate Pro
WP Migrate Lite is a great starting point for migrating your sites, but the premium version has advanced features to speed up your development workflow and give you faster, better migrations with less manual labor.
Push/pull functionality has always been one of the standout features of WP Migrate Pro. You can push or pull data directly to or from any two sites, as long as both have a copy of WP Migrate Pro. This capability lets you push or pull your database and files between sites with just a few clicks.
It isn’t possible to migrate a site from a remote server to a local server. Instead, WP Migrate Pro allows you to work from your local environment and initiate a pull on the remote site. You can then make changes safely, and use the push functionality to reproduce the changes on your production site. WP Migrate Pro’s ability to make incremental changes is a huge aid to busy developers.
Masterful Multisite Tools
Migrating a WordPress multisite can be challenging, as this artist’s rendering illustrates:
WP Migrate Pro gives you complete control over your multisite migrations, including the ability to push/pull the entire network or a single subsite from one multisite install to another, pull a single site to a network, push a network subsite to a single site install, replace a multisite with a single site, and much more.
Command Line Migrations
Graphic interfaces have their advantages, but the command line is often faster and allows for automation of certain tasks. WP Migrate integrates with WP-CLI, adding the
wp migrate command and related subcommands.
Installing WP-CLI opens a new world of possibilities with WP Migrate. Performing migrations from the command line is a definite time saver, but you can also use it to optimize your deployment scripts. CLI integration also gives you capabilities unmatched in the graphic interface: the ability to set up scheduled migrations or use it for remote backups.
Migrating even a small WordPress site can be tricky and time consuming if you’re relying on the built-in tools. Plus there’s really no reason to do so. WP Migrate Lite is completely free, regularly updated, and lets you perform find and replace searches, export entire sites with the themes, plugins, media, and core files intact, and provides flawless integration with Local.
When you require more advanced tools, there’s WP Migrate Pro, which adds push and pull capabilities, multisite tools, and integration with WP-CLI.
Do you use WP Migrate, the built-in WordPress tools, or another solution? Let us know in the comments.