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.
Exporting backups: wp migrator export
Section titled “Exporting backups: wp migrator export”Create a backup archive of the current WordPress installation.
# Full site backup (default destination in wp-content/migrator-backups/)wp migrator export
# Specify custom output pathwp migrator export --file=/backups/mysite-2026-11-20.tar.gz
# Export only the databasewp migrator export --only-db
# Export only media uploadswp migrator export --only-media
# Exclude specific directories and patternswp migrator export --exclude-dir=cache,node_modules --exclude-pattern="*.log,*.zip"
# Skip files larger than a designated thresholdwp migrator export --max-file-size=50MRestoring backups: wp migrator import
Section titled “Restoring backups: wp migrator import”Import an existing .tar.gz backup archive into the current WordPress installation.
# Full restore with automatic URL rewritingwp 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 onlywp migrator import /path/to/backup.tar.gz --only=database
# Selective restore: uploads onlywp migrator import /path/to/backup.tar.gz --only=uploads
# Skip automatic URL and path rewritingwp migrator import /path/to/backup.tar.gz --skip-replace
# Dry-run preview without writing to disk or databasewp migrator import /path/to/backup.tar.gz --dry-runSerialization-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.
# Preview what would be updated across the databasewp migrator replace https://old-domain.com https://new-domain.com --dry-run
# Execute live replacementwp migrator replace https://old-domain.com https://new-domain.com
# Replace filesystem absolute pathswp 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.
Pulling a site: wp migrator pull
Section titled “Pulling a site: wp migrator pull”On the destination server, run:
wp migrator pull https://source-store.com- On the first run, the command prints an authentication key.
- In the source site wp-admin, navigate to Migrator > Pull and Push and paste the key.
- Re-run
wp migrator pull https://source-store.com. - The database streams in chunks with automatic URL rewriting, followed by modified
wp-contentfiles. If interrupted, running the command again resumes where it stopped.
Pushing file changes: wp migrator push
Section titled “Pushing file changes: wp migrator push”To sync local or staging file modifications back to the remote server:
wp migrator push https://target-store.comAutomating via crontab
Section titled “Automating via crontab”You can trigger automated command-line backups using your operating system crontab:
# Run a daily database backup at 02:00 AM0 2 * * * /usr/local/bin/wp migrator export --only-db --path=/var/www/html > /dev/null 2>&1