WordPress Site Migration to New Hosting
WordPress migration is a task with several pitfalls: absolute paths in database, serialized data, different PHP and MySQL versions, SSL certificates. Correct procedure minimizes downtime to zero.
Tools
WP-CLI + rsync — professional approach for VPS. Full process control, minimal downtime.
All-in-One WP Migration plugin — convenient for shared hosting, file size limitation in free version (512 MB).
Duplicator — creates installer package, installed like a regular site.
Migration via WP-CLI (Recommended)
1. Export from source:
# Files
rsync -avz --exclude='.git' --exclude='node_modules' \
/var/www/old-host.com/ user@new-server:/var/www/new-host.com/
# Database
wp db export --add-drop-table - | gzip > /tmp/wordpress-db.sql.gz
scp /tmp/wordpress-db.sql.gz user@new-server:/tmp/
2. On new server — environment setup:
# Create database
mysql -u root -e "
CREATE DATABASE wordpress_new CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'new-password';
GRANT ALL PRIVILEGES ON wordpress_new.* TO 'wp_user'@'localhost';"
# Import database
gunzip -c /tmp/wordpress-db.sql.gz | mysql -u root wordpress_new
3. Update wp-config.php:
define('DB_NAME', 'wordpress_new');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'new-password');
define('DB_HOST', 'localhost');
4. Replace URL in database:
# MANDATORY before URL replacement
wp search-replace 'http://old-host.com' 'https://new-host.com' \
--all-tables \
--report-changed-only
# For staging (don't change URL immediately)
wp search-replace 'old-host.com' 'new-host.com' \
--all-tables \
--skip-columns=guid
wp search-replace correctly handles serialized data — unlike manual SQL UPDATE.
5. Testing on new server (before DNS change):
# Add to /etc/hosts on your computer
1.2.3.4 new-host.com www.new-host.com
Check: homepage, products/posts, forms, payment, login, images.
6. DNS change:
Lower TTL of A record to 300 seconds 24 hours before migration. After switchover — wait for propagation (up to 48 hours, usually 1–4 hours).
Serialized Data
Problem of manual URL replacement in database: values like a:2:{s:3:"url";s:22:"http://old-host.com/";} contain string length. When replaced, length changes, serialization breaks.
wp search-replace solves this automatically. If using another tool — sed or phpMyAdmin — data can be corrupted.
Different PHP Versions
If old hosting — PHP 7.4, new — PHP 8.2: verify compatibility of all plugins and themes. Most modern plugins support PHP 8.x, but some old ones don't.
# Check PHP errors after migration
tail -f /var/log/php/error.log
SSL on New Server
certbot --nginx -d new-host.com -d www.new-host.com
After certificate issuance — ensure FORCE_SSL_ADMIN is set in wp-config.php.
Timeline
WordPress site migration up to 5 GB with testing and DNS switchover — 3–5 hours. Large site with additional integrations — 6–8 hours.







