Documentation

WP-CLI Command – Push/Pull Subcommands

wp migratedb <push|pull> <url> <secret-key>
  [--find=<strings>] 
  [--replace=<strings>]
  [--regex-find=<strings>]
  [--regex-replace=<strings>] 
  [--case-sensitive-find=<strings>]
  [--case-sensitive-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=<all|since-date>]
  [--media-date=<yyyy-mm-dd>]
  [--media-subsites=<blog-id|subsite-url>]
  [--subsite=<blog-id|subsite-url>]
  [--theme-files=<all|theme-one,theme-two,theme-etc>]
  [--plugin-files=<all|plugin-one,plugin-two,plugin-etc>]
  [--exclude-theme-plugin-files=<string>]

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.

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

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

  Should be used in conjunction with the --regex-find=<strings> argument.

  A replace string may contain references of the form \n or $n, with the latter
  form being the preferred one. Every such reference will be replaced by the text 
  captured by the n'th parenthesized pattern used in the --regex-find pattern.

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

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

[--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=<all|since-date>]
  Perform a migration of the media files. Requires the Media Files Addon.

  Accepted values:

  * all - push or pull all media
  * since-date - compares and migrates media files added since a certain date, specified by the --media-date option

[--media-date=<yyyy-mm-dd>]
  Only used when migrating media files with the --media-files=since-date value

  Accepted values:
  * yyyy-mm-dd - date from which to migrate media files. Only files added since this date will be migrated.    

[--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.

[--theme-files=<all|theme-one,theme-two,theme-etc>]
  Perform a migration of the theme files. Requires the Theme & Plugin files addon.

  Accepted values:

  * all - Downloads all themes from the remote site.
  * A comma separated list of themes to migrate. See `wp theme list` for a list
    of theme slugs.
  * Requires the Theme and Plugin Files addon.

[--plugin-files=<all|plugin-one,plugin-two,plugin-etc>]
  Perform a migration of the plugin files. Requires the Theme & Plugin files addon.

  Accepted values:

  * all - Downloads all plugins from the remote site.
  * A comma separated list of plugins to migrate. See `wp plugin list` for a list
    of theme slugs.
  * Requires the Theme and Plugin Files addon.

[--exclude-theme-plugin-files=<string>]
  A comma-separated list of theme or plugin files and folders that should be excluded
  from the migration.

  * Requires the Theme and Plugin Files addon. 

Deprecated Options (available up to WP Migrate DB Pro v1.9)

[--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)

Examples

Pull from example.com to example.dev with a standard find and replace; don’t replace GUIDs; backup all local tables that begin with install’s table prefix; pull 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=all

Push to example.com from example.dev with a 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 all media since the 1st of January 2021:

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,'the best examples on the world' 
  --backup=wp_posts,wp_postmeta,custom_table 
  --media=since-date
  --media-date=2021-01-01

Pull from example.com to example.dev with a standard find and replace; only pull the wp_posts and wp_postmeta tables, include all media files:

wp migratedb pull http://example.com [secret key] \
 --find=//example.com,/path/to/example.com 
 --replace=//example.dev,/path/to/example.dev 
 --include-tables=wp_posts,wp_postmeta
 --media=all

Pull from example.com to example.dev with a standard find and replace; include all media files created since the 1st of January 2021:

wp migratedb pull http://example.com [secret key] \
  --find=//example.com,/path/to/example.com 
  --replace=//example.dev,/path/to/example.dev 
  --media=since-date
  --media-date=2021-01-01

Pull from example.com to example.dev with a standard find and replace; include all media files and all theme and plugin files:

wp migratedb pull http://example.com [secret key] \ 
  --find=//example.com,/path/to/example.com 
  --replace=//example.dev,/path/to/example.dev
  --media=all 
  --theme-files=all 
  --plugin-files=all