Migrating a Large WordPress Site


Migrating a WordPress site is generally a straightforward process. Make a backup of the current site, upload files, and import database onto the new web host. Moving a large website requires extra handling. Have you ever attempted to move a site with 100GB of storage? Tell me, how did that go?

Of course migrations do require extra steps to complete like updating DNS and installing SSL. But for the sake of this post I’m just going to focus on the actual site migration part. Let’s dig into a few options for doing just that.

Option 1) Full site migration using SSH

I typically like migrating sites over SSH. For a large site a few adjustments are required. Start by making a backup on the current site. Over SSH that can typically be accomplished like so.

# Move into the directory where WordPress lives. On Kinsta that's under ~/public.
cd ~/public/

# Generates a WordPress database export using WP-CLI
wp db export

# Move back to home directory
cd ~

# Generates a zip of the main public folder with date timestamp
zip -r "$(date +'%Y-%m-%d_%H-%M')_sitename.zip" public/

# Move backup to a WordPress public accessible URL
mv "$(date +'%Y-%m-%d_%H-%M')_sitename.zip" public/

If this backup method isn’t possible due to disk space, or lack of SSH, then I recommend installing ManageWP and use their paid $2/month backup service to generate the backup. ManageWP does a great job of handling very large backups.

On the destination site, manually create a migrate.sh script and grant it execute permissions chmod +x migrate.sh. Copy the contents of script from CaptainCore itself. For Kinsta hosted sites I recommend putting this script in the ~/private directory.

The larger the site, the longer this migration will take. To make sure it completes successfully we’ll need to run this script directly on the destination site as a background process using screen -R. Simply SSH to the new WordPress site, run screen -R and then run the following to kick off the migration script.

cd ~/public
~/private/migrate.sh --url="<link-to-public-accessible-backup.zip>"

The migration script will proceed to download the zip file, extract it, and override the existing WordPress site. You can safely disconnect from SSH and reconnect later to check in on its progress. Use screen -R to resume the background session.

Option 2) Incrementally sync files with Rclone

Rclone is a command application. With Rclone installed begin by adding SFTP connections to Rclone by typing rclone config. I recommend naming them something like sftp-sitename-source and sftp-sitename-destination. With that you can do an incremental remote to remote SFTP sync like so. Rclone will magically download and upload each file.

rclone sync sftp-sitename-source:public/wp-content/ sftp-sitename-destination:public/wp-content/ --progress

It’s always recommended to run this command with the --dry-run argument, as a simple typo can be quite destructive. Once the initial sync has completed the migration can be finished by manually exporting/importing the database and switching over DNS. To make sure any new files are moved over you can simply run the above command and it will incrementally copy over any missing files.