Skip to content

Backgrounds

How-to Guides

Technical References

VIP Dashboard /

Data sync from production to non-production environments

Data syncs on WordPress VIP occur only from production environments to non-production environments. Data syncs facilitate testing and QA of new features and allows teams to accurately reproduce and examine errors in a non-production environment.

WordPress VIP’s UnionFS allows media files uploaded to the production environment to be available to non-production environments in read-only mode. After a data sync, media file URLs on the target environment will automatically point to the shared files.

Actions that occur during a data sync

The operation is designed to not impact the production site in any way; all processing happens on the target environment:

  1. The target environment is protected via “maintenance mode”; this prevents access to the site while the data is being restored and manipulated, and ensures no changes can be made (and lost) during this time.
  2. The most recent backup from production is loaded into the target environment.
  3. Occurrences of the primary production domain in the database is replaced with the primary domain for the target environment. For example, if the production site domain is  example.com and the target non-production site domain is example-com-develop.go-vip.net, then all instances of example.com will be replaced with example-com-develop.go-vip.net in the target database after the sync.
  4. Caches are flushed.
  5. Jetpack is re-connected.
  6. Maintenance mode is deactivated.
  7. A cron event (vip_go_migration_cleanup) is fired for further cleanup. The vip_go_migration_cleanup hook can also be used for custom cleanup of your application data.

Note

For WordPress multisite environments on VIP, data syncs require a domain mapping config file.

Running a data sync via the VIP Dashboard

Data syncs can be initiated in the VIP Dashboard. Once logged into the VIP Dashboard

  • Navigate to the “Data” link in the left-hand navigation menu.
  • Choose the destination environment for the data sync at the top of the dashboard (e.g., “Develop”).
  • Click on “Copy from Production”.
  • Follow the prompts in the dashboard and click on the “Copy Data” button when ready.

Running a data sync via CLI

To run the following commands, VIP-CLI must first be installed on your local machine.

Step 1: Find the application name or ID you wish to sync

You can do this with the vip app list command, which will give you back a list of apps. You want the name or the id.

Step 2: Initiate the sync

Run the sync command with the app name, e.g. vip sync --app=my-app, or the app id, e.g. vip sync --app=000. You will be prompted for the environment you wish to sync to, i.e. the target environment. You can get more information about sync command options by using the help parameter, i.e. vip sync --help.

Custom cleanup operations

The vip_go_migration_cleanup hook can be used for custom cleanup of your application data. Some examples of cleanup operation include removing production API keys or performing brief data manipulation.

Note

The cleanup hook runs after maintenance mode is lifted.

Example code that shows you how to use this cleanup event:

/**
 * Run some custom cleanup after a migration.
 *
 * @uses vip_go_migration_cleanup
 */
function my_action_vip_go_migration_cleanup() {
    // Safety first: Don't do anything in 
    // the production environment
    if ( 'production' === VIP_GO_APP_ENVIRONMENT ) {
        return;
    }
 
    delete_option( 'my_social_api_token' );
}
add_action( 'vip_go_migration_cleanup', 'my_action_vip_go_migration_cleanup' );

On a multisite, the cleanup hook is run individually on each subsite within that multisite.

Last updated: October 14, 2021