How to Clone from the Command Line (WP-CLI)
IMPORTANT: you’ll need to have WP CLI installed first. See this link for instructions. This is also an NS Cloner Pro feature, so you'll need to have pro plugin installed and active.
You can run the NS Cloner from the command line with all the same modes and options available as in the GUI.
Standard Cloning
Create an exact copy of an existing site at a new address. Multisite only.
wp ns-cloner clone_basic [--source=<id>] Source id of site to clone. Required. [--title=<title>] Title of target site. Required. [--name=<name>] Subdomain or subdirectory of target site. Required. [--tables=<tables>] Comma separated list of tables to clone. [--search=<search>] Comma separated list of search values. [--replace=<replace>] Comma separated list of replace values. [--no_users] Skip cloning all except current user if set. [--no_media] Skip copying all uploads files if set. [--schedule] String value of time to schedule future operation for. [--log] Log debugging information if set.
Note: the clone_basic
command was called clone
prior to NS Cloner Pro 4.0.5, and was changed to avoid conflicting with clone
as a PHP reserved keyword.
Clone Over an Existing Network Site
Overwrite an existing site with a copy of another site. Multisite only.
wp ns-cloner clone_over [--source=<id>] Source id of site to clone. Required. [--target=<id>] Comma separated list of site ids to clone over. Required. [--title=<title>] New title of target site. Optional. [--tables=<tables>] Comma separated list of database tables to clone. All by default. [--post_types=<posttypes>] Comma separated list of post types to clone. All by default. [--search=<search>] Comma separated list of custom search terms. [--replace=<replace>] Comma separated list of custom replacements. [--no_users] Skip cloning all except current user if set. [--no_media] Skip copying all uploads files if set. [--schedule] String value of time to schedule future operation for. [--log] Log debugging information if set.
Search and Replace
Perform a search and replacement operation on an existing multisite or single site. Similar to WP’s builtin search-replace tool but enables future scheduling, use of Cloner filters and actions, etc.
wp ns-cloner search_replace [--target=<id>] Comma separated list of site ids to clone over. Required. [--search=<search>] Comma separated list of custom search terms. Required. [--replace=<replace>] Comma separated list of custom replacements. Required. [--tables=<tables>] Comma separated list of database tables to clone. All by default. [--schedule] String value of time to schedule future operation for. [--log] Log debugging information if set.
Teleport / Remote Cloning
Clone a local site to a remote location.
wp ns-cloner clone_teleport [--remote-url=<url>] URL of remote site to clone to. Required. [--remote-key=<key>] Access key to remote site to clone to. Required. [--title=<title>] Title of target site. Required for clone to multisite. [--name=<name>] Subdomain or subdirectory of target site. Required for clone to multisite. [--source=<id>] Source id of site to clone. Required for clone from multisite. [--title=<title>] Title of target site. [--tables=<tables>] Comma separated list of database tables to clone. All by default. [--post_types=<posttypes>] Comma separated list of post types to clone. All by default. [--search=<search>] Comma separated list of custom search terms. [--replace=<replace>] Comma separated list of custom replacements. [--no_users] Skip cloning all except current user if set. [--no_media] Skip copying all uploads files if set. [--schedule] String value of time to schedule future operation for. [--log] Log debugging information if set.