Sync Script

Version 1.1.0 Updated March 26th, 2019

Sync Script

This sync script is a Bash script, not a WordPress plugin, and is compatible with Bedrock-based WordPress installs.

Avoid the need for a WordPress plugin that handles database and media library migrations/synchronization by using WP-CLI aliases and rsync.

Sync in any direction:

  • Development to staging
  • Development to production
  • Staging to development
  • Production to development
  • Staging to production
  • Production to staging

WP-CLI performs a search-replace during the sync to make sure that your domain always matches the correct environment.

Optionally turn on a Slack notification when the sync direction is up or horizontal.

This script must be manually configured to fit your environment setup before it can properly work. Instructions are included, and the initial config should take just a few minutes and you won’t have to touch it again.

Examples include both Trellis and Kinsta based setups. Valet and other local development setups on host machines are also supported.

oh my god this so much faster than WP Migrate DB Pro 🔥

Kelly Mears Kelly Mears

This is so much faster and fluid than using the Delicious Brains plugin. I know they both offer different advantages and disadvantages as this needs Bedrock to function. Thanks for offering it at a good price. Highly recommended.

Joshua James Joshua James

Requirements

  • Bedrock-based WordPress install
  • Working local development setup ( Windows is supported in WSL)
  • Deployed and installed remote environments

Usage

Place the sync script in a directory called site/scripts/.

$ ./sync.sh production development

🔄 Would you really like to ⚠️ reset the development database (https://example.test)
   and sync down from production (https://example.com)? [y/N]

✅ Able to connect to production
✅ Able to connect to development

🔄 Sync from production to development complete.

Troubleshooting

Unable to connect to development

Make sure that your local development setup is up and running.

Unable to connect to production or staging

Make sure that you’re able to successfully connect with a SSH connection with the same details configured for the same WP-CLI alias.

If your SSH connection doesn’t fail, make sure WordPress is first already installed.

Join over 6,000 subscribers on our newsletter to get the latest Roots updates, along with occasional tips on building better WordPress sites.

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?

“Easily the best WordPress email I get.” Colin OBrien

Follow us on Twitter @rootswp

Ready to checkout?