Migrate WordPress with zero downtime by testing on the new server via hosts file overrides, reducing DNS TTL pre-cutover, and executing a delta database copy.
Key Takeaways
- Pre-cutover prep requires reducing DNS TTL to 5 minutes to accelerate global propagation.
- Hosts file overrides allow developers to test database integrity before making DNS live.
- Delta database copies are mandatory for WooCommerce or community sites to prevent transaction loss.
- Always use WP-CLI to import and export databases to avoid execution timeouts.
Migrating WordPress Without Downtime: A Developer's Step-by-Step Playbook
Moving a high-traffic WordPress website or a client portfolio to a new hosting provider is one of the most nerve-wracking tasks a developer can perform. If done incorrectly, you risk database corruption, broken file paths, lost customer orders, search engine ranking drops, and extended periods of site downtime that can cost businesses thousands of dollars.
However, migrations do not have to be stressful. By following a structured development protocol, you can clone, test, and cutover a website to a new server with **zero downtime** and complete data integrity. This process relies on a technique called "Hosts File Override Testing," which allows you to validate the new server before changing your live DNS settings.
In this step-by-step playbook, we outline the exact migration protocol used by senior web engineers to transfer complex WordPress sites safely.
Phase 1: Pre-Migration Audit and Preparation
Before copying a single file, you must audit the existing website to ensure compatibility with the new server environment:
- **Check PHP Version Compatibility:** Ensure your new host supports the PHP version running on your current site (e.g. PHP 8.1 or 8.2). Running older PHP code on a newer PHP server will trigger fatal errors.
- **Audit Database Size:** Clean up your database before migrating. Delete expired transients, spam comments, and old post revisions to reduce the backup file size and accelerate transfer speeds.
- **Identify Hardcoded Domains:** Check if your theme or plugins contain hardcoded IP addresses or file paths, as these will break on the new server.
- **Lower DNS TTL (Time to Live):** This is the most critical pre-migration step. Log into your DNS provider (e.g., Cloudflare, GoDaddy) and reduce the TTL of your domain's A record to 300 seconds (5 minutes). Do this 24 to 48 hours before the migration. This ensures that when you switch to the new server, DNS changes propagate globally in minutes rather than days.
Phase 2: Database and File Duplication
Once auditing is complete, copy the website files and database. For small sites, standard plugins like Duplicator suffice. For high-traffic sites, manual migration via SFTP and command-line tools is safer and faster.
Step 1: Export the Database: Use WP-CLI to export your database cleanly. This avoids timeout errors that occur when using web-based exports like phpMyAdmin:
`wp db export backup.sql --allow-root`
Step 2: Compress and Transfer Files: Compress your entire `/wp-content/` directory and file structure into a single archive (ZIP or tar.gz) and download it via SFTP:
`tar -czf site-files.tar.gz public_html/`
Step 3: Upload and Extract: Upload the archive to your new server's root folder and extract it. Create a new MySQL database on the new server, note the database credentials, and import your SQL file:
`wp db import backup.sql --allow-root`
Step 4: Update wp-config.php: Open the `wp-config.php` file on your new server and update the `DB_NAME`, `DB_USER`, `DB_PASSWORD`, and `DB_HOST` variables to match your new database credentials.
Phase 3: Migrating WordPress Multisite Networks
If your WordPress installation is a Multisite network, migrations contain additional configuration complexities that must be addressed:
- **Domain Mapping Verification:** Check that all subdomains or subdirectories are properly mapped in your new host's dashboard.
- **Wildcard SSL Setup:** Ensure your new host supports and has generated a wildcard SSL certificate to cover all network subdomains during propagation.
- **Configure wp-config.php for Multisite:** Verify that the multisite constants (like `MULTISITE`, `SUBDOMAIN_INSTALL`, and `DOMAIN_CURRENT_SITE`) are correctly aligned with the new server paths.
Additionally, check your database's `wp_blogs` and `wp_site` tables to verify that the main network domains and relative folder structures match the configuration directory on your new hosting server.
Phase 4: Handling Large Asset Libraries via Rsync
For massive websites containing tens of gigabytes of media uploads, using standard SFTP or ZIP downloads will fail due to timeout limits. Instead, web developers use `rsync` via SSH:
Rsync transfers files directly from server to server, compressing data on the fly and resuming transfers automatically if the connection drops. The command format to migrate your uploads folder is:
`rsync -avz --progress -e ssh user@oldserver:/var/www/public/wp-content/uploads/ /var/www/newserver/wp-content/uploads/`
This command copies the entire uploads folder without intermediate local downloads, preserving file timestamps and ownership settings. This is much faster because it bypasses local storage bandwidth limits entirely.
Phase 5: Updating URLs and Serialized Data via WP-CLI
If your domain name is changing during the migration, or if you need to update path definitions, do not use search-and-replace queries in standard MySQL. WordPress stores arrays as serialized data (which includes string character counts). If you replace `http://old.com` (14 chars) with `https://newsite.com` (19 chars) directly in SQL, the serialized string lengths will mismatch, causing plugins to break.
Instead, use WP-CLI's search-replace tool, which safely deserializes, replaces, and reserializes data:
`wp search-replace "http://old.com" "https://newsite.com" --skip-columns=guid --allow-root`
Adding the `--skip-columns=guid` flag ensures that WordPress RSS feed identifiers remain unchanged, preventing subscribers from receiving duplicate feed notifications.
Phase 6: Configuring System-Level Cron Jobs
WordPress uses a built-in file called `wp-cron.php` to handle scheduled tasks (like publishing scheduled posts, running security scans, and sending email notifications). By default, WordPress runs this file in the background on every single page view. On high-traffic sites, this creates unnecessary PHP resource usage. During migrations, it is best practice to disable the virtual cron and set up a system-level cron:
- **Disable Virtual Cron:** Add `define('DISABLE_WP_CRON', true);` to your `wp-config.php` file.
- **Configure Linux Crontab:** Log into your new server via SSH and edit the cron table: `crontab -e`. Add a new line to execute the cron file directly every 10 minutes: `*/10 * * * * wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1`
This configuration ensures that scheduled tasks run reliably at fixed intervals, without forcing your active web visitors to wait for cron execution threads to finish compiling.
Phase 7: Migrating Redirect Rules at the Nginx Level
If you are running redirection plugins, they query the database on every page view, adding performance overhead. High-traffic migrations should involve moving redirect rules out of plugins and placing them directly into Nginx configuration files:
`rewrite ^/old-slug/$ /new-slug/ permanent;`
Placing these rewrite rules directly into your Nginx virtual host configurations allows the web server to handle redirect routing without invoking PHP workers, keeping your site fast and lightweight.
Phase 8: Post-Migration SMTP Verification
Often, after migrating to a new host, contact forms and order emails stop sending because server-level PHP mail is blocked by default on premium clouds. To resolve this:
- **Install an SMTP Plugin:** Configure a dedicated SMTP plugin (like WP Mail SMTP) to route emails through an external transactional sender (like SendGrid, Mailgun, or Postmark).
- **Verify SPF Records:** Update your DNS SPF record to include your new hosting IP or mail provider: `v=spf1 include:mailgun.org ~all`.
- **Validate DKIM and DMARC:** Ensure your keys are fully set up at your DNS level to verify email authenticity and prevent emails from landing in spam folders.
Phase 9: The Secret Weapon – Hosts File Override Testing
At this stage, your files and database are active on the new server. However, your domain still points to the old server. To test the new site, you must force your computer's operating system to resolve the domain to the new server's IP address, bypassing public DNS.
This allows you to navigate the new site, test forms, and verify layouts as if the site were live, while the rest of the world still sees the old site.
How to edit your Hosts file:
On macOS or Linux: Open your terminal and run the following command to edit the hosts file using the Nano text editor:
`sudo nano /etc/hosts`
On Windows: Run Notepad as an Administrator and open the file located at:
`C:\Windows\System32\drivers\etc\hosts`
Add a new line at the bottom of the file containing your new server's IP address, followed by your domain name:
`192.0.2.1 yourdomain.com www.yourdomain.com`
Save and exit. Clear your browser cache and visit your website. Your browser is now loading the website directly from the new server. Navigate the dashboard, test payment gateways (in sandbox mode), check image links, and resolve any layout issues. Once verified, delete this line from your hosts file to return to standard DNS resolution.
Phase 10: Database Synchronization (Delta Copy)
If your site is static, you can proceed to the DNS switch. However, if you are migrating an active WooCommerce store or a community forum, customers have made purchases or posted comments during the time it took to migrate the site.
To prevent data loss, you must execute a "Delta Copy" right before DNS switchover:
- **Place Old Site in Maintenance:** Put a temporary maintenance banner on your old site to block new database writes.
- **Export the Delta SQL:** Export only the database from the old server again.
- **Import to New Server:** Overwrite the database on the new server with the fresh export, ensuring that all recent customer orders are captured.
Phase 11: DNS Switchover and Monitoring
You are now ready to make the new site live globally. Log into your DNS registrar and update the A record IP address to point to your new server.
Because you reduced the TTL to 300 seconds in Phase 1, the new DNS record will propagate worldwide almost instantly. Monitor DNS propagation using a tool like DNSChecker.org. Once the domain has fully propagated to the new server, you can safely terminate your old hosting account.
Phase 12: DNS Security and DNSSEC Activation
When migrating your DNS to a new server or moving to a new DNS provider (like Cloudflare), it is critical to address DNS security. Hackers use techniques like DNS spoofing and cache poisoning to redirect user traffic to malicious clone sites without altering your hosting server itself.
To prevent this, you should enable DNSSEC (Domain Name System Security Extensions) at your domain registrar. DNSSEC adds cryptographic signatures to your DNS records, validating their authenticity for client browsers. During migration, you must temporarily disable DNSSEC before updating your A records, wait for the new DNS records to propagate, and then re-enable DNSSEC at the registrar with the new security keys provided by your new DNS host, ensuring complete security continuity.
Phase 13: Post-Migration Analytics and Google Search Console Audit
Once your DNS switch is complete and your site is live on the new hosting server, the final phase is verification of tracking pixels and search console indexing properties. Server migrations can sometimes introduce structural anomalies, such as HTTP/2 settings changes, SSL certificate errors, or modified redirects, which can affect Googlebot's crawling capacity.
To prevent crawl issues, log into Google Search Console and inspect several core pages. Check the crawl stats report to ensure Googlebot is successfully communicating with your new server IP without encountering DNS or server timeout errors. Additionally, check your Google Analytics or analytics scripts to verify that page views are being tracked continuously and that visitor sessions are not being fragmented by server-side redirects.
Summary Checklist for Zero-Downtime Migration
- DNS TTL reduced to 300 seconds 24 hours before migration.
- Database pruned and optimized to minimize file sizes.
- Files and database transferred and configured on the new server.
- Hosts file override tested to validate new site rendering.
- Delta database synchronization executed to prevent transaction loss.
- DNS A record updated and global propagation verified.

Swapan Kumar Manna
View Profile →Product & Marketing Strategy Leader · AI & SaaS Growth Expert
Strategic Growth Partner & AI Innovator with 14+ years of experience scaling 20+ companies. As Founder & CEO of Oneskai, I specialize in Agentic AI enablement and SaaS growth strategies to deliver sustainable business scale.
Next Reads
Carefully selected articles to help you on your journey.