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 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 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, just as you would interact with it within the WordPress dashboard:

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-files= "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

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
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