WP Site Replicator
Quickly create replicas of large production websites from WordPress eXtended RSS (WXR) export files.
This command relies on writing directly to the WP database via WP DB API so both post and term tables should be empty.
Install it as a WP CLI package:
wp package install wpsh/wp-cli-replicator
Export content from the source site:
Use the WP Options Importer plugin to export the site options. The output should be a single
Parse the exported WordPress eXtended RSS or WXR into JSON files for site users, terms and posts:
wp replicator parse-wxr path/to/wxr/directory
path/to/wxr/directoryis the path to the directory with all the XML files.
All XML files
path/to/wxr/files/*.xmlare parsed and stored in the
Please note that you may need to specify
--url for all commands if you're running WordPress multisite.
Empty the site content where you want to import the content:
wp site empty --yes
wp replicator import-options "path/to/options.json"
path/to/options.jsonis the path to the exported options.
wp replicator import-users "path/to/users.json"
path/to/users.jsonis the path the user list generated from the XML export.
All existing users with the same login name will be deleted and new users created with a random password because WordPress export doesn't include the passwords. All users will need to reset their passwords. Use
wp user update USERNAME --user_pass="YOURNEWPASSWORD"to update a password for a specific user.
Import taxonomies and terms:
wp replicator import-terms "path/to/terms.json"
path/to/terms.jsonis the path the term list generated from the XML export.
wp replicator import-posts "path/to/json"
path/to/jsonis the path to the directory with all
Created by Kaspars Dambis.