Skip to main content
  1. All Posts/


Tools Open Source Sync WordPress

wp-site-sync is a bash shell script that synchronizes a local WordPress instance to an external site. It’s designed to keep a localhost development instance up-to-date against a development, staging, or production server instance.
This script is provided as-is, and is not production ready.
I’ve made it available because a few people I know were curious to take a look. If more people can be saved the pain caused by WordPress’s insanity of embedding absolute URLs, all the better.
The script currently does the following:

  • Backs up the remote database and copies it locally
  • Loads the backup into your local database
  • Does a search/replace on the site URL
  • synchronizes the files using the rsync utility


  • Ability to run bash shell scriptsI run this on a Mac. It should run on any Unix-like bash shell, but it hasn’t been tested.
  • SSH access to the remote server
    SSH key works best, otherwise you’re entering a lot of passwords.
  • WP-CLI ( installed on remote and local servers.
  • A local LAMP (Linux/Apache/MySQL/PHP) development stack


  • uses a site configuration file (site file) in ~/.wp-site-sync. A site configuration file is required for each pair of sites you want to sync.


List site configuration files

List available site configuration files (ls of ~/.wp-site-sync directory):

$ ./ list

Perform a site sync

Perform a site sync using the specified site configuration file:

$ ./

Prefix the site file with an at-sign (“@”).

Site Configuration File Example

#!/usr/bin/env bash
# Sync Configuration File Example
# --> example.localhost

# Common

# Remote

# Local

# Initialize
date_stamp=`date +"%Y-%m-%d-%k%M"`

To-Do / Wishlist / Roadmap

  • Better document the site configuration file
  • Test if the remote backup directory exists
  • Site configuration file creation assistance
  • Test if wp-cli is installed
  • Prompt for a password once if no SSH key access
  • Test if uncommitted code on remote
  • Put SHA of current GIT commit in db backup file name
  • Test if branches between remote and local are different
  • Ability to re-restore local from existing remote db backup
  • Test if MySql is running locally
  • Database backup file cleanup
  • Automatically create ~/.wp-site-sync directory if it doesn’t exist
  • Update wp search-replace to use the –all-tables parameter (or be smarter about adding additional tables)
  • Detect problematic plugins and provide warnings of additional actions required (e.g. Elementor requires regeneration of files via UI tool)
  • Find a way to test if wp-cli commands completed properly (they always return success, it seems)