wpsh / wp-cli-replicator
Installs: 61 162
Dependents: 0
Suggesters: 0
Security: 0
Stars: 34
Watchers: 4
Forks: 4
Open Issues: 3
Type:wp-cli-package
Requires
- wp-cli/wp-cli: ^2.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-27 05:57:24 UTC
README
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
Install it as a WP CLI package:
wp package install wpsh/wp-cli-replicator
Usage
Export Content
Export content from the source site:
-
Use the WordPress Importer plugin or the
wp export
command to export the site content. -
Use the WP Options Importer plugin to export the site options. The output should be a single
options.json
file.
Prepare Import
-
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
where
path/to/wxr/directory
is the path to the directory with all the XML files.All XML files
path/to/wxr/files/*.xml
are parsed and stored in thepath/to/wxr/directory/json
directory --users.json
,terms.json
andposts-*.json
.
Import Content
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
-
Import options:
wp replicator import-options "path/to/options.json"
where
path/to/options.json
is the path to the exported options. -
Import users:
wp replicator import-users "path/to/users.json"
where
path/to/users.json
is 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"
where
path/to/terms.json
is the path the term list generated from the XML export. -
Import posts:
wp replicator import-posts "path/to/json"
where
path/to/json
is the path to the directory with allpost-*.json
files.
Credits
Created by Kaspars Dambis.