Skip to content

WP-CLI reference

Migrator provides a complete set of WP-CLI commands. The command line runs directly in the terminal without browser execution timeouts or web server memory restrictions, making it the preferred tool for large WooCommerce stores and scripted automation.

Create a backup archive of the current WordPress installation.

Terminal window
# Full site backup (default destination in wp-content/migrator-backups/)
wp migrator export
# Specify custom output path
wp migrator export --file=/backups/mysite-2026-11-20.tar.gz
# Export only the database
wp migrator export --only-db
# Export only media uploads
wp migrator export --only-media
# Exclude specific directories and patterns
wp migrator export --exclude-dir=cache,node_modules --exclude-pattern="*.log,*.zip"
# Skip files larger than a designated threshold
wp migrator export --max-file-size=50M

Import an existing .tar.gz backup archive into the current WordPress installation.

Terminal window
# Full restore with automatic URL rewriting
wp migrator import /path/to/backup.tar.gz
# Selective restore: restore plugins and themes only (ideal under DISALLOW_FILE_MODS)
wp migrator import /path/to/backup.tar.gz --only=plugins,themes
# Selective restore: database only
wp migrator import /path/to/backup.tar.gz --only=database
# Selective restore: uploads only
wp migrator import /path/to/backup.tar.gz --only=uploads
# Skip automatic URL and path rewriting
wp migrator import /path/to/backup.tar.gz --skip-replace
# Dry-run preview without writing to disk or database
wp migrator import /path/to/backup.tar.gz --dry-run

Serialization-safe search and replace: wp migrator replace

Section titled “Serialization-safe search and replace: wp migrator replace”

Safely rewrite domain names, URLs, or filesystem paths across your database. Migrator inspects PHP serialized objects and updates internal string length counts, preventing data corruption.

Terminal window
# Preview what would be updated across the database
wp migrator replace https://old-domain.com https://new-domain.com --dry-run
# Execute live replacement
wp migrator replace https://old-domain.com https://new-domain.com
# Replace filesystem absolute paths
wp migrator replace /var/www/vhosts/old/ /home/forge/new/

Direct server sync: wp migrator pull and wp migrator push

Section titled “Direct server sync: wp migrator pull and wp migrator push”

Migrator can stream a site between two active servers over HTTP without manual file transfers.

On the destination server, run:

Terminal window
wp migrator pull https://source-store.com
  1. On the first run, the command prints an authentication key.
  2. In the source site wp-admin, navigate to Migrator > Pull and Push and paste the key.
  3. Re-run wp migrator pull https://source-store.com.
  4. The database streams in chunks with automatic URL rewriting, followed by modified wp-content files. If interrupted, running the command again resumes where it stopped.

To sync local or staging file modifications back to the remote server:

Terminal window
wp migrator push https://target-store.com

You can trigger automated command-line backups using your operating system crontab:

# Run a daily database backup at 02:00 AM
0 2 * * * /usr/local/bin/wp migrator export --only-db --path=/var/www/html > /dev/null 2>&1