Infrastructure

How to migrate WooCommerce without losing revenue

Binadit Tech Team · May 07, 2026 · 7 min leer
How to migrate WooCommerce without losing revenue

What you will achieve and why it matters

This guide walks you through migrating a WooCommerce store to new infrastructure without downtime or lost transactions. Revenue continues flowing during the migration, customers never see errors, and your store operates normally throughout the process.

The approach uses DNS switching combined with real-time database synchronization to ensure zero interruption to your business operations.

Prerequisites and assumptions

Before starting this migration, ensure you have:

  • Full administrative access to both source and destination servers
  • SSH access to both environments
  • Database credentials for the existing WooCommerce installation
  • DNS management access (ability to modify A records)
  • At least 24-48 hours to complete the migration process
  • A maintenance window identified for the final switchover

This guide assumes your WooCommerce store handles regular transactions and downtime would result in immediate revenue loss. We also assume you're migrating to infrastructure that matches or exceeds current performance requirements.

Step-by-step implementation with concrete commands, configs and code

Phase 1: Prepare the destination environment

Set up your new server environment with identical PHP and MySQL versions. Install WordPress and WooCommerce but don't configure them yet.

# Install required packages
sudo apt update
sudo apt install nginx mysql-server php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-xml php8.1-zip

# Create database for WooCommerce
mysql -u root -p
CREATE DATABASE woocommerce_new;
GRANT ALL PRIVILEGES ON woocommerce_new.* TO 'woouser'@'localhost' IDENTIFIED BY 'secure_password';
FLUSH PRIVILEGES;
EXIT;

Configure Nginx with the same server blocks and SSL certificates as your current setup:

server {
    listen 443 ssl http2;
    server_name yourstore.com;
    
    ssl_certificate /path/to/certificate.pem;
    ssl_certificate_key /path/to/private-key.pem;
    
    root /var/www/woocommerce;
    index index.php;
    
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Phase 2: Create initial database copy

Export your current WooCommerce database and import it to the new server. This creates your baseline copy:

# On source server - create database dump
mysqldump -u username -p --single-transaction --routines --triggers woocommerce_db > woocommerce_backup.sql

# Transfer to destination server
scp woocommerce_backup.sql user@newserver:/tmp/

# On destination server - import database
mysql -u woouser -p woocommerce_new < /tmp/woocommerce_backup.sql

Update the WordPress configuration to point to the new database:

# wp-config.php on destination server
define('DB_NAME', 'woocommerce_new');
define('DB_USER', 'woouser');
define('DB_PASSWORD', 'secure_password');
define('DB_HOST', 'localhost');

Phase 3: Set up database synchronization

Create a synchronization script that copies new orders and customer data from the live site to your staging environment. This script runs every few minutes to keep data current:

#!/bin/bash
# sync-woocommerce.sh

# Get timestamp of last sync
LAST_SYNC=$(cat /var/log/woo-sync-timestamp 2>/dev/null || echo "1970-01-01 00:00:00")

# Export only new/modified data since last sync
mysqldump -u source_user -p'source_password' -h source_host \
  --where="post_modified >= '$LAST_SYNC'" \
  --single-transaction source_db wp_posts > /tmp/new_posts.sql

mysqldump -u source_user -p'source_password' -h source_host \
  --where="user_registered >= '$LAST_SYNC'" \
  --single-transaction source_db wp_users > /tmp/new_users.sql

# Import to destination
mysql -u woouser -p'secure_password' woocommerce_new < /tmp/new_posts.sql
mysql -u woouser -p'secure_password' woocommerce_new < /tmp/new_users.sql

# Update timestamp
date '+%Y-%m-%d %H:%M:%S' > /var/log/woo-sync-timestamp

Set this script to run every 5 minutes via cron:

*/5 * * * * /path/to/sync-woocommerce.sh >> /var/log/woo-sync.log 2>&1

Phase 4: File synchronization

Keep media uploads and plugin files synchronized between environments:

# Initial media sync
rsync -avz --delete source_server:/var/www/woocommerce/wp-content/uploads/ /var/www/woocommerce/wp-content/uploads/

# Ongoing sync every 10 minutes
*/10 * * * * rsync -avz --delete source_server:/var/www/woocommerce/wp-content/uploads/ /var/www/woocommerce/wp-content/uploads/

Phase 5: Pre-migration testing

Test the new environment using a temporary domain or IP address. Verify that:

  • All pages load correctly
  • Product catalog displays properly
  • Shopping cart functions work
  • Payment gateways connect successfully
  • Order processing completes without errors

Run a test transaction using a payment gateway's test mode:

# Test WooCommerce API connectivity
curl -X GET "https://staging.yourstore.com/wp-json/wc/v3/orders" \
  -u "consumer_key:consumer_secret" \
  -H "Content-Type: application/json"

Phase 6: DNS preparation and final switch

Reduce your DNS TTL to 300 seconds (5 minutes) at least 24 hours before migration:

# Update DNS record TTL
yourstore.com.    300    IN    A    old.server.ip.address

During your maintenance window, perform the final synchronization and switch DNS:

# Stop sync script to prevent conflicts
sudo systemctl stop cron

# Final database sync
/path/to/sync-woocommerce.sh

# Final file sync
rsync -avz --delete source_server:/var/www/woocommerce/wp-content/uploads/ /var/www/woocommerce/wp-content/uploads/

# Update DNS to point to new server
yourstore.com.    300    IN    A    new.server.ip.address

Verification: how to confirm it works

Monitor these metrics and checks to confirm your migration succeeded:

DNS propagation check

# Verify DNS changes from multiple locations
dig @8.8.8.8 yourstore.com
dig @1.1.1.1 yourstore.com
nslookup yourstore.com

Application functionality tests

Run automated tests against key store functions:

# Test homepage response time
curl -w "@curl-format.txt" -o /dev/null -s "https://yourstore.com/"

# Test product page loading
curl -I "https://yourstore.com/shop/"

# Test cart functionality
curl -X POST "https://yourstore.com/?wc-ajax=add_to_cart" -d "product_id=123"

Monitor these key metrics for 24-48 hours after migration:

  • Page load times (should match or improve from baseline)
  • Order completion rates (track through WooCommerce analytics)
  • Payment gateway success rates
  • Server response times and error rates
  • Database query performance

Revenue tracking validation

Compare revenue metrics before and after migration:

# WooCommerce sales report query
SELECT 
  DATE(post_date) as order_date,
  COUNT(*) as order_count,
  SUM(meta_value) as daily_revenue
FROM wp_posts p
JOIN wp_postmeta pm ON p.ID = pm.post_id
WHERE p.post_type = 'shop_order'
  AND pm.meta_key = '_order_total'
  AND p.post_date >= DATE_SUB(NOW(), INTERVAL 7 DAY)
GROUP BY DATE(post_date);

Common pitfalls to avoid

Several issues can disrupt WooCommerce migrations if not handled properly:

Session data inconsistency: Customer shopping carts may empty during DNS switchover. Implement session data synchronization or accept that active sessions may reset during the brief transition period.

Payment gateway webhook URLs: Update webhook URLs in payment gateways (Stripe, PayPal, etc.) to point to the new server before switching DNS. Missing this step can cause payment confirmations to fail.

SSL certificate timing: Ensure SSL certificates are properly installed and tested on the new server before DNS changes. Certificate errors will immediately impact customer trust and conversion rates.

Database connection limits: Synchronization scripts can exhaust database connections. Monitor connection usage and implement connection pooling if needed.

Next steps and related reading

After completing your WooCommerce migration, focus on performance optimization and monitoring setup. Configure proper caching layers, implement database query optimization, and establish monitoring for key business metrics.

For ongoing infrastructure reliability, consider implementing structured migration processes for future moves. Understanding real uptime measurement helps you validate that your new infrastructure delivers the reliability your business requires.

Monitor your new environment closely for the first month. Track page load times, conversion rates, and server performance metrics to ensure the migration improved rather than degraded your store's performance. Consider implementing automated testing to catch issues before they impact customers.

Maintaining revenue during infrastructure changes

WooCommerce migrations require careful coordination between technical execution and business continuity. The approach outlined here minimizes risk by maintaining parallel environments and switching traffic only after thorough validation. This method ensures your store continues generating revenue throughout the migration process.

Need this running in production without building it yourself? See our infrastructure management services or schedule a call.