Skip to content
Sync remote wordpress database to your local instance
PHP
Branch: master
Clone or download
Pull request Compare This branch is 6 commits ahead, 2 commits behind timneutkens:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
composer.json
composer.lock
dbsync-command.php

README.md

WP-CLI DB Sync

Remote to local database import tool for wp-cli

This is a wp-cli command version of this gist

Installation

composer require timneutkens/wp-cli-dbsync:^1.0.0

wp package install https://github.com/timneutkens/wp-cli-dbsync.git <- you need to have wp-cli installed, so that it can work.

If the one above won't work try the one below

wp package install https://github.com/benferch/wp-cli-dbsync.git <- you need to have wp-cli installed, so that it can work.

Configuration

This command uses wp-cli-ssh.

To get started use their instructions to setup a remote host:

Add an ssh section to your wp-cli.yml/wp-cli.local.yml, as seen in the sample config. You indicate the ssh command templates for each host you want to connect to. The template variable %cmd% is replaced with the full command to run on the server; the %pseudotty% template variable is replaced with -t/-T depending on whether you're on a TTY or piping the command output.

For a step-by-step guide, please refer to the wiki.

Now you can run the following command:

wp dbsync <host here>

The command will import the database. After that it will search replace the old home url to the new home url using wp search-replace. The new home url will be guessed using wp option get home. Beware that if you define WP_HOME this command will return that url instead of the url set in the wp_options table. Optionally you can provide --new-base-url=http://example.com to override this behaviour.

Replace <host here> with the host you just setup in your wp-cli.yml/wp-cli.local.yml.

You can’t perform that action at this time.