WP-CLI UpdraftPlus Documentation

Before using WP CLI:

Before using WP CLI, make sure it is installed. For installation of WP CLI, refer to this page: https://make.wordpress.org/cli/handbook/installing/.

Using WP CLI with UpdraftPlus:

UpdraftPlus Premium  provides WP CLI commands to take backups and manage backups. It is not mandatory to login to the admin dashboard to use UpdraftPlus. Here are some commands you could use with UpdraftPlus’ WP-CLI.

    • To install the plugin (free version): wp plugin install updraftplus
    • To install and activate the plugin: wp plugin install updraftplus --activate
    • To list all installed plugins: wp plugin list
    • To update all plugins: wp plugin update --all

The below are the commands that can be run to interact with UpdraftPlus Premium, just as you would interact with it within the WordPress dashboard:

Connect

To connect your premium plugin to your account and activate your licence:

wp updraftplus connect –email=”[email protected]” [–password=”MyPassword123″ or –password-file=”/path/to/file”]

This includes the following parameters:

Option Requirement Description Example
[--email] Required: Yes The email address that is registered on UpdaftPlus.com wp updraftplus connect --email="[email protected]"
[--password] Required: No The associated password with the registered email address wp updraftplus connect --password="MyPassword123"
[--password-file] Required: No The path to a file that contains an associated password with the registered email address wp updraftplus conect="/path/to/file"

 

Backup

To take a backup, simply run the command below. Generally, the default options are those which are saved in your settings:

wp updraftplus backup

You can enhance the backup command by adding the following parameters to it:

Option Requirement Description Example
[--label] Required: No Add a label to the backup wp updraftplus backup --label="UpdraftplusCLI Backup"
[--exclude-db] Required: No Excludes database entity from being backed up. By default database is included in backup wp updraftplus backup --exclude-db=true
[--send-to-cloud] Required: No Exclude the backup being sent to remote storage. By default, if set up, backups will be sent to remote storage wp updraftplus backup --send-to-cloud=false
[--include-files] Required: No Decides which backup file entity should be added to backup. By default its value is same as Settings > UpdraftPlus Backups > Settings > Include in files backup.

You have to pass multiple values by comma-separating them. [--include-files] Possible backup entities are plugins, themes, uploads, wpcore and others.

wp updraftplus backup --include-files= "plugins,themes,uploads"
[--include-tables] Required: No Indicates which tables should be added to database backup. By default all WordPress tables are included in the database backup.

You canpass multiple values by comma-separating them. You can pass the table name with the WordPress database table prefix or without the prefix.

wp updraftplus backup --include-tables= "wp_posts,wp_postmeta"

 

Restore

To restore a backup, run the command below.

wp updraftplus restore <nonce>

The <nonce> is the unique identifier for the backup set that you wish to restore.

You can enhance the restore command by adding the following parameters to it:

Option Requirement Description Example
[--components] Required: No The components to restore. Multiple component names should separate by comma (,). If you do not pass this argument, UpdraftPlus will restore all backup entities in the given backup (“all”). wp updraftplus restore b290ee083e9e --components="db,plugins,themes"
[--db-decryption-phrase] Required: No If the database backup is encrypted, provide the database decryption phrase here. wp updraftplus restore b290ee083e9e --db-decryption-phrase="password"
[--over-write-wp-config] Required: No Whether the wp-config.php file will be overwritten or not. This option requires the “More files” add-on. wp updraftplus restore b290ee083e9e --over-write-wp-config=true
[--incremental-restore-point] Required: No Incremental restore point. This option requires the “Support for incremental backups” add-on. wp updraftplus restore b290ee083e9e incremental=5
[--migration] Required: No Whether the restoration is a migration or not. If you are restoring another site backup, This option’s value will be considered. Otherwise this is ignored. This option requires the “Migrator” add-on. wp updraftplus restore b290ee083e9e --migration=true
[--site-id-to-restore] Required: No To restore a specific sub-site in a Multisite setup. The option value -1 is for restoring all sites. If you are restoring a Multisite backup, this options’ value will be considered. Otherwise this is ignored. This option only affects the restoration of the database and uploads – other file entities (such as plugins) in WordPress are shared by the whole network. This option requires the “Network / Multisite” add-on. wp updraftplus restore b290ee083e9e --site-id-to-restore=2
[--delete-during-restore] Required: No Whether to delete backup archives after they have been restored. Defaults to false. wp updraftplus restore b290ee083e9e --delete-during-restore=true
[--db-dummy-restore] Required: No Restores the backup. When we pass ‘–db-dummy-restore=true’ to our command it will run a dummy restore of the database with a random prefix and delete all dummy tables after finishing the process. The purpose of adding this option is to check if the process times out during the restore backup. It’s totally optional. If we don’t pass this option restores process would work as it currently does. wp updraftplus restore [nonce] --components="db" --db-dummy-restore=true
[--collate] Required: No If specified, and if the database contains any collations unavailable on the local MySQL server, then this will be substituted in its place. wp updraftplus restore [nonce] --components="db" --collate=utf8mb4_general_ci
[--charset] Required: No If specified, and if the database contains any charsets unavailable on the local MySQL server, then this will be substituted in its place. wp updraftplus restore [nonce] --components="db" --charset=utf8mb4

UpdraftClone

To create a clone, simply run the command below. You must provide a WordPress user (that exists on the site your creating the clone from) and a clone key which can be created in the my account section on UpdraftPlus.com:

wp updraftplus updraftclone –user=”USER NAME/EMAIL/ID” –clone-key=”CLONE_KEY”

You can enhance the UpdraftClone command by adding the following parameters to it:

Option Requirement Description Example
[--user] Required: Yes A user that exists on the site your creating the clone from, you can pass a username, email or user ID. wp updraftplus updraftclone --user="[email protected]" --clone-key="CLONE_KEY"
[--clone-key] Required: Yes A UpdraftClone Key created in the my account section on UpdraftPlus.com. wp updraftplus updraftclone --user="[email protected]" --clone-key="CLONE_KEY"
[--php] Required: No The PHP version to use on the clone, defaults to the PHP version WP-CLI is running under. wp updraftplus updraftclone --user="USER NAME/EMAIL/ID" --clone-key="CLONE_KEY" --php="7.4"
[--wp] Required: No The WP version to use on the clone, defaults to the WP version the site is running under. wp updraftplus updraftclone --user="USER NAME/EMAIL/ID" --clone-key="CLONE_KEY" --wp="5.8"
[--region] Required: No The region to create the clone in defaults to London. wp updraftplus updraftclone --user="USER NAME/EMAIL/ID" --clone-key="CLONE_KEY" --region="London"
[--package] Required: No The clone package to boot defaults to the starter package. wp updraftplus updraftclone --user="USER NAME/EMAIL/ID" --clone-key="CLONE_KEY" --package="size2"
[--admin-only] Required: No A boolean to indicate if the clone should only allow admins to login defaults to False wp updraftplus updraftclone --user="USER NAME/EMAIL/ID" --clone-key="CLONE_KEY" --admin-only
[--wp-only] Required: No A boolean to indicate if we should boot a blank clone defaults to False wp updraftplus updraftclone --user="USER NAME/EMAIL/ID" --clone-key="CLONE_KEY" --wp-only

In addition to backing up your website, you can also run the following commands to return extra information:

Option Description Example
existing_backups Displays existing backups wp updraftplus existing_backups
get_latest_full_backup Get the job_id of the latest backup that includes every entity (i.e. plugins, themes, …) configured to be backed up in your settings. wp updraftplus get_latest_full_backup
existing_backups Displays existing backups wp updraftplus existing_backups
backup_progress See backup progress by job_id wp updraftplus backup_progress <Job ID>

e.g. wp updraftplus backup_progress c23c41b1f567

get_most_recently_modified_log Displays the most recently modified log file’s contents wp updraftplus get_most_recently_modified_log
get_log Displays the log content for a given backup job_id wp updraftplus get_log <Job ID>

e.g. wp updraftplus get_log c23c41b1f567

activejobs_delete Terminates a running backup job wp updraftplus activejobs_delete <Job ID>

e.g. wp updraftplus activejobs_delete c23c41b1f567

rescan_storage Rescan either local or remote storage for backup sets. Default: remote wp updraftplus rescan_storage [--type=<remote|local>]

e.g. wp updraftplus rescan_storage local

incremental_backups List incremental backups wp updraftplus incremental_backups

 

Commands for assisting with migration and UpdraftCentral –

Option Description Example
create_migration_key Creates a RSA keypair for migration one part is saved the other part needs to be copied/sent to the remote site. wp updraftplus create_migration_key <name> <size>

e.g. wp updraftplus create_migration_key my_key_name 2048

create_updraftcentral_key Creates a UpdraftCentral key. NOTE: this command must be run with the –user flag otherwise the key created will be invalid

<where_send>: “updraftpluscom” for hosted UpdraftCentral or the host of the self-hosted version

wp --user=<User ID> updraftplus create_updraftcentral_key <name> <size> <use-alternative-connection-method> <where-send>

e.g. p --user=1 updraftplus create_updraftcentral_key my_key_name 2048 0 updraftpluscom

search_and_replace Runs a search/replace operation using UpdraftPlus’s search/replace mechanism. wp updraftplus search_and_replace <search> <replace> [--page-size=5000] [--which-tables=<comma separated list>]

e.g. wp updraftplus search_and_replace example.com new_example.com 1000 options,users