WP-CLI reference
Esta página aún no está disponible en tu idioma.
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 .migrator archive of the database and wp-content. The default excludes (cache folders, other backup plugins’ folders, node_modules, .git, log files over 10 MB) apply here too.
# Full site backup (a dated file in the backups folder)wp migrator export
# Write the archive to a path of your choicewp migrator export --output=/backups/mysite.migrator
# Leave parts out: database, media, themes, inactive-themes, plugins,# inactive-plugins, muplugins, cache, spam-comments, post-revisions,# transients, sessions, action-schedulerwp migrator export --exclude=media,spam-comments,post-revisions
# Leave out exact tables, wp-content paths and file name patternswp migrator export --exclude-tables=wp_actionscheduler_logs --exclude-files=uploads/2019 --exclude-pattern="*.log,*.zip"
# Skip files larger than 50 MBwp migrator export --max-file-size=50
# Gzip the finished archive (import detects it)wp migrator export --compressRestoring backups: wp migrator import
Section titled “Restoring backups: wp migrator import”Import a .migrator archive into the current site. The source site’s URLs and paths are rewritten to this site’s. On a single site, a different table prefix is moved to this site’s prefix; a multisite restore still needs matching prefixes.
# Full restore with automatic URL rewritingwp migrator import /path/to/backup.migrator
# Selective restore: plugins and themes only (useful under DISALLOW_FILE_MODS)wp migrator import /path/to/backup.migrator --only=plugins,themes
# Parts you can pick: database, plugins, themes, uploads, otherwp migrator import /path/to/backup.migrator --only=database
# Database only, no wp-content files, no confirmation promptwp migrator import /path/to/backup.migrator --skip-files --yes
# Safe mode: every plugin except Migrator stays off afterwards, wp-admin offers to switch them back onwp migrator import /path/to/backup.migrator --safe-mode
# Set a new password for an administrator (login or email) after the restoreMIGRATOR_ADMIN_PASSWORD='a-long-password' wp migrator import /path/to/backup.migrator --admin-user=adminWithout MIGRATOR_ADMIN_PASSWORD, --admin-user asks for the password at a prompt.
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.
# 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 compressed full backup every day at 02:000 2 * * * /usr/local/bin/wp migrator export --compress --path=/var/www/html > /dev/null 2>&1