Migrating WordPress to HostingSwift
Move a WordPress site — files, database and URLs — without broken images or lost posts.
WordPress migrations go wrong in predictable ways. Handle these and it is routine.
Prepare
Back up the current site completely — files and database. See Database backups.
Note the plugins and theme, and any custom
wp-config.phpconstants.Check the PHP version on the old host so you match or exceed it.
Export the database:
wp db export backup.sql --path=/var/www/html # if WP-CLI is available
# or
mysqldump --single-transaction wordpress_db > backup.sqlCopy the files
rsync -avz --delete /var/www/html/ user@newhost:/var/www/html/Or use a migration plugin if you prefer a GUI. Either way, the database is the part that needs care.
Import the database
mysql new_db < backup.sqlUpdate wp-config.php with the new database name, user and password.
Fix the URLs — the step everyone forgets
WordPress stores absolute URLs in the database. If the domain changes, every image and link may still point at the old domain. Fix it properly:
wp search-replace 'https://old.example' 'https://new.example' --all-tables --preciseWithout WP-CLI, use a serialised-data-aware search-replace plugin — a plain SQL REPLACE corrupts serialised PHP arrays and can quietly break your theme options.
Test thoroughly
Homepage, a single post, a category archive.
Images (the most common casualty).
Login and admin.
Forms, and the email they send.
Permalinks (Settings → Permalinks → Save, to flush rewrite rules).
Cut over
Lower the TTL, point DNS at the new host, then restore the TTL. See Migrating your hosting.
After the move
HTTPS — issue a certificate and force the redirect; see Free TLS certificates.
Caching — add a page cache, the biggest speed win; see WordPress performance.
Search-engine settings — make sure nothing is set to noindex from a staging setup.
Keep the old host for a few days as rollback, then cancel.
Related reading