The greatest risk during a WordPress migration is not copying files, but saving the database and file storage at different points in time. For example, the database may already contain a new order while its attachment file has not yet been included in the backup. Or a media file may be copied before its database record is created.
Such a backup may appear complete, but after restoration the site can have incomplete orders, different image versions, missing imports, or incorrect settings. To avoid this, temporarily stop all processes that modify the site, create a backup at a coordinated point in time, and verify it on staging before switching DNS.
What a Coordinated WordPress Backup Means
A coordinated backup is a set of database and files that correspond to one logical state of the site. In practice, this means that orders, posts, settings, media files, and data generated by background tasks must not change while the backup is being created.
The problem most often occurs because of active traffic, external WP-Cron, Action Scheduler in WooCommerce, product imports, form submissions, or payment service webhooks. Even a difference of several minutes between exporting the database and copying uploads can matter for a dynamic site.
It is important to distinguish between database consistency and the consistency of the entire backup. The `--single-transaction` option helps create a consistent export of transactional InnoDB tables, but it does not create a shared snapshot of the database and file system. Files must be protected from changes separately.
- The database should be exported when no new records are being created.
- The `uploads` directory, themes, and plugins should be copied after or during a controlled site freeze.
- Queues, imports, and integrations must be stopped, and their state must be recorded.
- The backup must be tested through an actual restoration, not just checked for the presence of an archive.
Preparing the Site Before Creating a Backup
Start by defining a short maintenance window and recording the operation's start time. Inform the team so that no one launches imports, updates content, or changes plugin settings during this period.
Enable maintenance mode or another method of blocking new user activity. This may not be sufficient for an online store: some payment services, webhooks, or server-side scripts may continue sending requests. If necessary, temporarily restrict access to administrative and API endpoints at the infrastructure level.
Stop external WP-Cron, system cron jobs, Action Scheduler, and background imports. If the site uses WooCommerce or CRM integrations, check for tasks with a `pending` or `processing` status. Do not delete them without consideration: record the list and restore processing in a controlled manner after the migration.
Before copying, make sure there is enough free disk space for the SQL file and archives. Also check where non-standard upload directories, additional configuration files, and files generated by plugins are located.
- Create a list of domains, subdomains, databases, directories, and external integrations.
- Record the versions of PHP, WordPress, the theme, key plugins, and web server settings.
- Make sure access to the old server will remain available until verification is complete.
- Do not update WordPress or plugins immediately before the migration unless this is a separate part of the plan.
Exporting the Database with WP-CLI
For MySQL or MariaDB databases with InnoDB tables, WP-CLI is a convenient option. The command below creates an SQL dump using a single transaction. This reduces the risk of receiving partially changed tables during the export, but it does not replace stopping new records from being created on the site.
Before running the command, make sure it is executed from the root of the correct WordPress installation and uses the correct `wp-config.php`. After completion, confirm that the file exists, has a non-zero size, and that the command finished without errors.
If the database contains non-InnoDB tables, snapshot behavior may differ for them. This is especially important for older installations or plugins that have created their own tables. Table types can be checked at the database management system level; for a critical project, this should be done before migration.
- Store the dump outside the server being migrated and restrict access to it.
- Do not include passwords, API keys, or other secrets in a public archive.
- If necessary, compress the SQL file after verification, for example into a protected archive.
- Record the dump size, creation date, and file checksum separately.
wp db export backup.sql --single-transaction
sha256sum backup.sql
Which Files to Copy and Which Can Be Left Behind
The minimum set of files usually required to restore WordPress includes `wp-content/uploads`, the active theme, installed plugins, and `mu-plugins` if they are used. Also preserve configuration files, web server rules, and non-standard directories required by the specific project.
The `uploads` directory must be copied in full, including subdirectories and files that may have been uploaded outside the standard media manager. For large sites, use a tool that preserves file structure, permissions, and modification times rather than copying files through a browser-based control panel.
Caches, logs, temporary files, and generated thumbnails do not always need to be migrated: they can be recreated if this is confirmed by the site's configuration. Do not remove them automatically if you are unsure whether a plugin stores important data or the results of long-running operations in its cache.
- Always check `wp-content/uploads` and non-standard plugin directories.
- Save `wp-config.php` separately and transfer it only through a secure channel.
- Do not include secrets in an open archive or repository.
- After copying, compare file counts, directory sizes, and checksums of critical files.
- Make sure the web server user on the new host will have the required access to the files.
rsync -aHAX --delete wp-content/uploads/ user@new-server:/path/to/site/wp-content/uploads/
rsync -aHAX wp-content/themes/ user@new-server:/path/to/site/wp-content/themes/
rsync -aHAX wp-content/plugins/ user@new-server:/path/to/site/wp-content/plugins/
rsync -aHAX wp-content/mu-plugins/ user@new-server:/path/to/site/wp-content/mu-plugins/
Restoring the Backup on Staging and Verifying It
Do not switch DNS immediately after copying is complete. First, create a separate staging environment with compatible versions of PHP, MySQL or MariaDB, the web server, and the required extensions. Restore the database, files, and configuration, then check the site as both a user and an administrator.
If staging uses a different domain, changing the URL requires care. WordPress may contain serialized data, so a simple search and replace of strings in SQL can corrupt values. Use a tool that supports serialization, and work on a database copy first.
Basic checks can be performed with WP-CLI. Checksum verification helps identify modified core files, but the result must be interpreted correctly: modified or customized files may produce warnings and do not necessarily indicate a failed migration.
- Check the homepage, internal URLs, search, forms, authentication, and error pages.
- Open several old and new images, uploads, and documents.
- Check orders, users, products, posts, settings, and queues.
- Review PHP, web server, WordPress, and critical plugin logs.
- Make sure staging does not send real emails, process payments, or deliver webhooks.
wp core verify-checksums
wp option get siteurl
wp option get home
Final Cutover and Queue Activation
After successful verification, prepare the final cutover window. You will usually need to enable maintenance mode again, stop background processes once more, and create an up-to-date database dump and file synchronization. This is especially important if new data has appeared on the old site since the first backup.
After uploading the final data, check DNS, the TLS certificate, domain URLs, email, external APIs, and caching rules. Do not remove the old server immediately: it should remain available as a comparison source and rollback option.
Start queues only after checking the site on the new server. Initially, you can allow limited processing and review the logs to avoid creating duplicate emails, orders, or imports. Once the site is stable, disable maintenance mode and test it from different types of devices.
- Lower the DNS TTL in advance if this is supported by the current DNS infrastructure.
- Record the exact time of the final backup and the moment DNS was changed.
- Check that WP-Cron is not running on both the old and new servers at the same time.
- Prepare a rollback plan that includes the old host, its DNS, configuration, and the latest working backup.
- Create another backup after the site has launched successfully on the new infrastructure.
Common WordPress Backup Mistakes
The most common mistake is assuming that an archive of files and an SQL file automatically constitute a working backup. Without a test restoration, there is no way to know whether the dump is intact, all files were copied, and the environment versions are compatible.
Another problem is copying the database and `uploads` without stopping new records from being created. This creates inconsistencies that often appear only after migration: an image does not open, an order has no attachment, or an import is partially repeated.
It is also dangerous to migrate only the active theme or only the standard `uploads` directory while ignoring `mu-plugins`, custom modules, and server configuration. The file list must be based on the project's actual structure rather than a standard WordPress installation.
- Do not rely only on a backup created by a plugin if you have not tested its restoration.
- Do not store the backup and the only working copy of the site on the same server.
- Do not edit `wp-config.php` or the SQL archive in a public directory.
- Do not start queues before checking for duplicate and accurate data.
- Do not remove the old environment immediately after changing DNS.
Frequently asked questions
Is enabling maintenance mode enough for a coordinated backup?
No. Maintenance mode blocks or limits some user activity, but external WP-Cron, Action Scheduler, webhooks, and server-side imports may continue changing the database and files. They must be checked and, if necessary, stopped separately.
Do I need to copy the entire wp-content directory?
Not always. The usual requirements are `uploads`, themes, plugins, and `mu-plugins`. Caches and temporary files can often be left behind, but first check whether a specific plugin stores important data or the results of long-running operations there.
Why does --single-transaction not guarantee a fully consistent backup?
It applies to consistent reads of transactional database tables, primarily InnoDB. The option does not freeze the file system or stop new WordPress requests, so files must be copied in a controlled mode.
How can I tell whether a backup can really be restored?
Deploy it to a separate staging environment with a compatible setup, import the database, restore the files, and check the site, media, forms, users, orders, queues, and integrations. A backup that has not undergone a test restoration remains only an assumption.
When can WP-Cron and Action Scheduler be started after migration?
After checking the domain, database, files, and external integrations on the new server. Start the queues in a controlled manner, review the logs, and check that duplicate imports, emails, or orders are not being created.
Conclusion
A reliable WordPress migration begins not with copying files, but with controlling changes on the site. Stop background processes, block new records, export the database in a coordinated mode, and copy the required files separately.
Then restore the backup on staging and verify it as a real website. Only after successful verification should you switch DNS, start the queues, and keep the old environment available until the monitoring period is complete.