Migrate a WP website from a single-server single-domain to a multi-server multi-domain installation

We are currently hosting a WordPress website at GoDaddy from the US that ultimately needs to serve customers in both China and the rest of the world.

For performance and security reasons we require to host both a .cn website from within China and a .com website from outside of China (the .cn and .com websites will be identical).

The .cn and .com websites have to be synchronised at all times and maintainable by a single WP Dashboard.

I believe that WP Multisite would not work here since the content would still be blocked by the Chinese Firewall when hosted from outside of China. And when hosted from within China would make access from outside of China too slow. Hence, the multi-domain multi-server installation required.

My question is whether such an architecture for WP exists and if there are any common/best practices for serving a multi-domain multi-server website?


I can think of one complication, the resources and links stored in the database contain the .com domain, this will make migration to a multi-domain website hard.

Topic sync domain multisite migration Wordpress

Category Web


The simplest way to create identical websites on different domains is to use the plugin Multiple Domain. This allows you to have a single WP install with one database serving two domains.

Next step is to copy this DB to a Chinese server, where create a script to copy DB and files from the main server outside of China. It should contain something as follows:

  echo -e "\nSyncing database..."
  ssh -i "$KEY_FILE" "$REMOTE_DOMAIN" "cd $REMOTE_PATH > /dev/null&&/user/bin/wp db export /tmp/wp.sql > /dev/null"
  scp -i "$KEY_FILE" $REMOTE_DOMAIN:/tmp/wp.sql wp.sql
  ssh -i "$KEY_FILE" $REMOTE_DOMAIN "rm /tmp/wp.sql"
  echo -e "Done."

  echo -e "\nImporting database..."
  wp --allow-root --quiet db import wp.sql
  echo -e "Done."

  rm wp.sql

  echo -e "\nSyncing uploads..."
  rsync -ase "ssh -i $KEY_FILE" --exclude "*backwpup*/*" $REMOTE_DOMAIN:"$REMOTE_PATH"/wp-content/uploads/* "$LOCAL_PATH"/wp-content/uploads
  echo -e "Done."

This script can be executed by cron every 5 min, for instance.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.