Delicious Brains

Documentation

WP-CLI Command – Push/Pull Subcommands

wp migratedb <push|pull> <url> <secret-key>
  [--find=<strings>] [--replace=<strings>]
  [--include-tables=<tables>] [--exclude-post-types=<post-types>]
  [--skip-replace-guids] [--exclude-spam] [--preserve-active-plugins]
  [--include-transients]
  [--backup=<prefix|selected|table_one,table_two,table_etc>]
  [--media=<compare|compare-and-remove|remove-and-copy>]
  [--media-subsites=<blog-id|subsite-url>]
  [--subsite=<blog-id|subsite-url>]

Allows you to run a push or pull migration.

Options

<url>
  The URL of the remote site. Should include the URL encoded basic
  authentication credentials (if required). e.g.
  http://user:password@example.com

  Must include the WordPress directory if WordPress is stored in a subdirectory.
  e.g. http://example.com/wp

<secret-key>
  The remote site's secret key.

[--find=<strings>]
  A comma separated list of strings to find when performing a string find
  and replace across the database.

  Table names should be quoted as needed, i.e. when using a comma in the
  find/replace string.

  The --replace=<strings> argument should be used in conjunction to specify
  the replace values for the strings found using this argument. The number
  of strings specified in this argument should match the number passed into
  --replace=<strings> argument.

  If omitted, a set of 2 find and replace pairs will be performed by default:

  1. Strings containing URLs referencing the source site will be replace
  by the destination URL.

  2. Strings containing root file paths referencing the source site will
  be replaced by the destination root file path.

[--replace=<strings>]
  A comma separated list of replace value strings to implement when
  performing a string find & replace across the database.

  Should be used in conjunction with the --find=<strings> argument, see it's
  documentation for further explanation of the find & replace functionality.

[--include-tables=<tables>]
  The comma separated list of tables to migrate. Excluding this parameter
  will migrate all tables in your database that begin with your
  installation's table prefix, e.g. wp_.

[--exclude-post-types=<post-types>]
  A comma separated list of post types to exclude. Excluding this parameter
  will migrate all post types.

[--skip-replace-guids]
  Do not perform a find & replace on the guid column in the wp_posts table.

[--exclude-spam]
  Exclude spam comments.

[--preserve-active-plugins]
  Preserves the active_plugins option (which plugins are
  activated/deactivated).

[--include-transients]
  Include transients (temporary cached data).

[--backup=<prefix|selected|table_one,table_two,table_etc>]
  Perform a backup of the destination site's database tables before
  replacing it.

  Accepted values:

  * prefix - Backup only tables that begin with your installation's
             table prefix (e.g. wp_)
  * selected - Backup only tables selected for migration
               (as in --include-tables)
  * A comma separated list of the tables to backup.

[--media=<compare|compare-and-remove|remove-and-copy>]
  Perform a migration of the media files. Requires the Media Files Addon.

  Accepted values:

  * compare - compares remote and local media files and only
              <uploads|downloads> those missing or updated
  * compare-and-remove - compares remote and local media files and only
                         <uploads|downloads> those missing or updated.
                         Removes <remote|local> media files that are not
                         found on the <local|remote> site
  * remove-and-copy - removes all <remote|local> media files and
                      <uploads|downloads> all <local|remote> media files
                      (skips comparison)

[--media-subsites=<blog-id|subsite-url>]
  Only transfer media files for selected subsites

  * Only applies to multisite installs
  * Separate multiple subsites with commas
  * Use Blog ID or URL of *<local|remote>* subsites

[--subsite=<blog-id|subsite-url>]
 * Push the given subsite to the remote single site install.
 * Requires the Multisite Tools addon.

Examples

Pull from example.com to example.dev with standard find and replace; don’t replace GUIDs; backup all local tables that begin with install’s table prefix; remove local media and copy down all remote media:

wp migratedb pull http://example.com [secret key] --find=//example.com,/path/to/example.com --replace=//example.dev,/path/to/example.dev --skip-replace-guids --backup=prefix --media=remove-and-copy

Push to example.com from example.dev with standard find and replace, additionally replace all occurrences of “the best examples on the internet” with “the best examples in the world”; only push wp_posts and wp_postmeta; backup wp_posts, wp_postmeta, and custom_table; push up new and updated media:

wp migratedb push http://example.com [secret key] --find=//example.dev,/path/to/example.dev,'the best examples on the internet' --replace=//example.com,/path/to/example.com --backup=wp_posts,wp_postmeta,custom_table --media=compare