> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mainwp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MainWP WP CLI Commands

> Complete reference for MainWP WP-CLI commands. Manage sites, sync data, handle updates, and automate WordPress management tasks from the command line.

MainWP includes WP-CLI integration for managing your MainWP Dashboard, configuring MainWP Child connection authentication, and restoring built-in backups on a Child Site from the command line. This enables automation, scripting, and advanced management workflows.

## What You'll Learn

* Available WP-CLI commands for site management
* How to sync, update, and manage sites via command line
* How to configure MainWP Child password authentication for a WordPress user
* How to restore a built-in backup on a Child Site from the command line
* Example automation scripts

## Prerequisites

* MainWP Dashboard v4.1.3 or later
* WP-CLI installed on your MainWP Dashboard server for `wp mainwp` commands
* WP-CLI available on the server hosting the child site for `wp mainwp-child` commands
* MainWP Child activated on the child site
* Child sites connected to your MainWP Dashboard for Dashboard-side management commands

For more information about WP-CLI, visit the [official WP-CLI documentation](https://wp-cli.org/).

## Built-In Help

WP-CLI lists every option for a command, including the ones that take a value such as `--site-url`, `--type`, `--slug`, `--ver` and `--ssl_verify`, with a short description and examples:

```bash theme={null}
wp help mainwp sites
wp help mainwp site
wp help mainwp updates
```

> [!NOTE]
>
> Running `wp mainwp sites` with no option prints a table of all child sites. The older `--list` and `--count` options still print the same table, but they are no longer listed in the help.

***

> [tab] Sites
>
> ## Sites Management
>
> Commands for managing multiple child sites simultaneously.
>
> ### List All Sites
>
> ```bash theme={null}
> wp mainwp sites --all-sites
> ```
>
> Displays every child site in your MainWP installation.
>
> ### Count All Sites
>
> ```bash theme={null}
> wp mainwp sites --all-sites-count
> ```
>
> Returns the total number of child sites.
>
> ### Connected Sites
>
> ```bash theme={null}
> wp mainwp sites --connected-sites
> ```
>
> Lists only child sites with active connections.
>
> ### Connected Sites Count
>
> ```bash theme={null}
> wp mainwp sites --connected-sites-count
> ```
>
> Returns count of actively connected child sites.
>
> ### Disconnected Sites
>
> ```bash theme={null}
> wp mainwp sites --disconnected-sites
> ```
>
> Lists child sites that are currently disconnected.
>
> ### Disconnected Sites Count
>
> ```bash theme={null}
> wp mainwp sites --disconnected-sites-count
> ```
>
> Returns count of disconnected child sites.
>
> ### Sync All Sites
>
> ```bash theme={null}
> wp mainwp sites --sync-sites
> ```
>
> Synchronizes data across all child sites.
>
> ### Check All Sites
>
> ```bash theme={null}
> wp mainwp sites --check-sites
> ```
>
> Verifies the status of all child sites.
>
> ### Disconnect Sites
>
> ```bash theme={null}
> wp mainwp sites --disconnect-sites 2,5
> ```
>
> Disconnects the child sites with the given comma-separated IDs.
>
> If a site cannot be disconnected, the command prints a warning for that site and moves on to the next one. If any site failed, the command ends with `Disconnect completed with errors` and a non-zero exit code, so scripts can detect the failure.
>
> > [!WARNING]
> >
> > Without site IDs, `--disconnect-sites` disconnects all of your child sites.

> [tab] Site
>
> ## Single Site Operations
>
> Commands for managing individual child sites. Replace `<id>` with the site ID.
>
> Every `wp mainwp site` command except `--add-site` needs a site ID. Without one, the command stops with `Empty site id.`
>
> ### Site Information
>
> ```bash theme={null}
> wp mainwp site --site <id>
> ```
>
> Retrieves comprehensive data for a specific child site.
>
> ```bash theme={null}
> wp mainwp site --site-info <id>
> ```
>
> Returns: site name, URL, WordPress version, PHP version, MainWP Child plugin version, PHP memory limit, MySQL version, active theme, and server IP address.
>
> ### Plugins
>
> ```bash theme={null}
> wp mainwp site --site-installed-plugins <id>
> wp mainwp site --site-installed-plugins-count <id>
> wp mainwp site --site-active-plugins <id>
> wp mainwp site --site-active-plugins-count <id>
> wp mainwp site --site-inactive-plugins <id>
> wp mainwp site --site-inactive-plugins-count <id>
> wp mainwp site --site-abandoned-plugins <id>
> wp mainwp site --site-abandoned-plugins-count <id>
> ```
>
> ### Themes
>
> ```bash theme={null}
> wp mainwp site --site-installed-themes <id>
> wp mainwp site --site-installed-themes-count <id>
> wp mainwp site --site-active-themes <id>
> wp mainwp site --site-inactive-themes <id>
> wp mainwp site --site-inactive-themes-count <id>
> wp mainwp site --site-abandoned-themes <id>
> wp mainwp site --site-abandoned-themes-count <id>
> ```
>
> ### Updates & Status
>
> ```bash theme={null}
> wp mainwp site --site-available-updates <id>
> wp mainwp site --site-available-updates-count <id>
> wp mainwp site --site-http-status <id>
> wp mainwp site --site-health-score <id>
> wp mainwp site --site-security-issues <id>
> ```
>
> ### Site Management
>
> **Add a new site:**
>
> Use the administrator password when the Child Site requires Password Authentication:
>
> ```bash theme={null}
> wp mainwp site --add-site --site-url=https://site.com --name=sitename --admin=adminuser --adminpassword='YOUR_ADMIN_PASSWORD'
> ```
>
> MainWP Dashboard 6.4 and later accepts `--adminpassword=<password>`. The flag must include a value. Password connections require HTTPS with certificate verification by default. Resolve certificate errors on the Child Site before retrying.
>
> If the Child Site requires a Unique Security ID, supply `--uniqueid`:
>
> ```bash theme={null}
> wp mainwp site --add-site --site-url=https://site.com --name=sitename --admin=adminuser --uniqueid=YOUR_SECURITY_ID
> ```
>
> Supply both `--adminpassword` and `--uniqueid` when MainWP Child requires both methods. Avoid leaving connection credentials in shared scripts or shell history.
>
> **Sync, reconnect, disconnect, or remove:**
>
> ```bash theme={null}
> wp mainwp site --sync-site <id>
> wp mainwp site --reconnect-site <id>
> wp mainwp site --disconnect-site <id>
> wp mainwp site --remove-site <id>
> ```
>
> ### Apply Updates
>
> ```bash theme={null}
> wp mainwp site --site-update-wordpress <id>
> wp mainwp site --site-update-plugins <id>
> wp mainwp site --site-update-themes <id>
> wp mainwp site --site-update-translations <id>
> ```
>
> **Update a specific item:**
>
> ```bash theme={null}
> wp mainwp site --site-update-item <id> --type=<plugin|theme> --slug=<slug>
> ```
>
> ### Plugin & Theme Control
>
> **Manage plugins:**
>
> ```bash theme={null}
> wp mainwp site --site-manage-plugin <id> --action=<activate|deactivate|delete> --plugin=<plugin-slug>
> ```
>
> **Manage themes:**
>
> ```bash theme={null}
> wp mainwp site --site-manage-theme <id> --action=<activate|deactivate|delete> --theme=<theme-slug>
> ```
>
> ### Check HTTP Status
>
> ```bash theme={null}
> wp mainwp site --check-site-http-status <id>
> ```
>
> Verifies HTTP status of a child site.

> [tab] Updates
>
> ## Updates Management
>
> Commands for controlling plugin and theme updates across sites.
>
> ### View Available Updates
>
> ```bash theme={null}
> wp mainwp updates --available-updates
> ```
>
> Shows all pending updates across all child sites.
>
> ### Ignored Updates (Global)
>
> ```bash theme={null}
> wp mainwp updates --ignored-plugins-updates
> wp mainwp updates --ignored-themes-updates
> ```
>
> Lists globally ignored plugin or theme updates.
>
> ### Ignored Updates (Per Site)
>
> ```bash theme={null}
> wp mainwp updates --site-ignored-plugins-updates <id>
> wp mainwp updates --site-ignored-themes-updates <id>
> ```
>
> Lists ignored updates for a specific child site.
>
> `--site-ignored-plugins-updates`, `--site-ignored-themes-updates`, `--ignore-update` and `--unignore-update` need a site ID. Without one, the command stops with `Empty site id.`
>
> ### Ignore Updates Globally
>
> ```bash theme={null}
> wp mainwp updates --ignore-updates --type=<plugin|theme> --slug=<slug> --name=<name>
> ```
>
> Globally ignores an update across all sites.
>
> ### Ignore Updates on Specific Site
>
> ```bash theme={null}
> wp mainwp updates --ignore-update <id> --type=<plugin|theme> --slug=<slug> --name=<name>
> ```
>
> Ignores a specific update on one child site.
>
> ### Unignore Updates Globally
>
> ```bash theme={null}
> wp mainwp updates --unignore-updates --type=<plugin|theme> --slug=<slug> [--ver=<version>]
> ```
>
> Reverses a global update ignore.
>
> ### Unignore Updates on Specific Site
>
> ```bash theme={null}
> wp mainwp updates --unignore-update <id> --type=<plugin|theme> --slug=<slug> [--ver=<version>]
> ```
>
> Reverses a site-specific update ignore.
>
> ### Unignore Options
>
> | Option | Description |
> | - | - |
> | `--type` | `plugin` or `theme` (required) |
> | `--slug` | Plugin file, such as `akismet/akismet.php`, or theme folder name (required) |
> | `--ver` | Version to unignore. Leave it out to unignore all versions. |
>
> Without `--ver`, the command unignores all versions, which is what `--ignore-updates` and `--ignore-update` store. A specific `--ver`, such as `--ver=5.3.1`, removes only that version from the ignored list and does not undo an ignore that covers all versions.
>
> `--ver` needs a value. The command refuses a bare `--ver`, an empty value or `0`, because those would otherwise unignore all versions on a site.
>
> ```bash theme={null}
> # Remove the global ignore for all versions of Akismet
> wp mainwp updates --unignore-updates --type=plugin --slug=akismet/akismet.php
>
> # Unignore version 5.3.1 of Akismet on site 3
> wp mainwp updates --unignore-update 3 --type=plugin --slug=akismet/akismet.php --ver=5.3.1
> ```

> [tab] MainWP Child
>
> ## MainWP Child Connection Authentication
>
> Run these commands from the child site's WordPress installation. The `settings` subcommand changes whether a specific WordPress user requires password authentication during the initial MainWP connection.
>
> The `settings` subcommand does not display current settings. Running `wp mainwp-child settings` without its required option returns an invalid arguments error.
>
> ### Disable Password Authentication
>
> ```bash theme={null}
> wp mainwp-child settings --disable-pwd-auth <username> 1
> ```
>
> Replace `<username>` with an existing WordPress username.
>
> > [!WARNING]
> >
> > Configure a [Unique Security ID](https://docs.mainwp.com/advanced/miscellaneous/mainwp-connection-security.md#unique-security-id) at **WordPress Admin > Settings > MainWP Child > Settings** before disabling password authentication. The CLI command changes only the selected user's password-authentication setting; it does not generate a Unique Security ID.
>
> ### Enable Password Authentication
>
> ```bash theme={null}
> wp mainwp-child settings --disable-pwd-auth <username> 0
> ```
>
> > [!NOTE]
> >
> > The username is required. A final value of `1` disables password authentication, while `0` enables it. Omitting the final value defaults to disabling password authentication, so use an explicit value in scripts.
>
> ## Restore a Built-In Backup
>
> Use `wp mainwp-child backup restore` to restore a [MainWP Built-In Backups](https://docs.mainwp.com/sites/backups/manage-backups.md) archive when WordPress Admin or the MainWP Dashboard is unavailable. The command uses the same restore engine as the Dashboard and requires MainWP Child 6.4 or later.
>
> ```bash theme={null}
> wp mainwp-child backup restore <archive> [--type=<full|db|files>] [--bundle=<dir>] [--yes]
> ```
>
> | Option | Description |
> | - | - |
> | `<archive>` | The archive file name, such as `backup-1718900000.zip`. For an encrypted bundle, use the archive file name recorded in the bundle's manifest. |
> | `--type` | What to restore: `full` (default), `db`, or `files`. |
> | `--bundle` | Directory containing a downloaded encrypted offsite copy: `manifest.json`, `manifest.json.hmac`, and the encrypted archive file or chunks. |
> | `--yes` | Confirms a restore that overwrites the live database. Required for `full` and `db`. |
>
> > [!WARNING]
> >
> > The command does not create a safety backup before restoring. Make sure you have a separate backup of the current site before any restore. Back up the affected files for `files`, the database for `db`, and both for `full`.
>
> ### Restore a Local Archive
>
> The archive must be in the Child Site's MainWP backup directory, a folder named `backup-` followed by a site-specific string under `wp-content/uploads/mainwp/`. If the file is missing, MainWP Child returns `Archive not found in the backup directory`.
>
> ```bash theme={null}
> wp mainwp-child backup restore backup-1718900000.zip --type=full --yes
> ```
>
> The command prints each restore phase and finishes with `Success: Restore completed.`
>
> ### Restore an Encrypted Offsite Copy
>
> If the local copy is gone and your backups use [archive encryption](https://docs.mainwp.com/sites/backups/manage-backups.md#encrypt-backup-archives), download the snapshot's files from your storage destination into a directory on the Child Site server. Provide your backup recovery passphrase in the `MAINWP_BACKUP_PASSPHRASE` environment variable, then pass the directory with `--bundle`:
>
> ```bash theme={null}
> IFS= read -r -s MAINWP_BACKUP_PASSPHRASE
> export MAINWP_BACKUP_PASSPHRASE
> wp mainwp-child backup restore backup-1718900000.zip --type=db --yes \
>   --bundle=/home/recover/4/37
> unset MAINWP_BACKUP_PASSPHRASE
> ```
>
> MainWP Child decrypts the archive into the backup directory and then restores it. A wrong passphrase stops the restore before any site content changes.
>
> > [!NOTE]
> >
> > The `--passphrase=<passphrase>` option also works with `--bundle`, but it exposes the passphrase in process lists and shell history. Use the environment variable instead.
>
> ### Restore to a Different Domain
>
> With MainWP Child 6.4.2 or later, a full or database restore keeps the destination site's **Site Address (URL)** (`home`) and **WordPress Address (URL)** (`siteurl`). MainWP rewrites source URLs in the restored database for the destination. If `WP_HOME` or `WP_SITEURL` is defined in `wp-config.php`, WordPress continues to use those definitions.
>
> Record both destination URLs before you restore. They can differ, for example when WordPress is installed in a subdirectory. If a URL constant is set, also record both stored option values using the check below.
>
> If MainWP reports that it rolled back the database, it restored the previous values. If it could not confirm the destination URLs, check which correction it prints.
>
> * If it prints `wp option update` and the matching URL constant is set, use the corresponding `wp eval` correction below. Otherwise, replace the placeholder in the printed command with the option's pre-restore stored value.
> * If it prints `wp option delete`, use that command to remove the option that was absent before the restore.
>
> Verify both stored values and check the site's links.
>
> #### Verify Stored URLs When Constants Are Set
>
> When `WP_HOME` or `WP_SITEURL` is set, the effective URL can look correct while the stored option still points to the source site. Run these read-only commands on the destination site before restoring to record the stored values. An empty result (`[]`) means the option is absent.
>
> ```bash theme={null}
> wp option list --search=home --format=json
> wp option list --search=siteurl --format=json
> ```
>
> If a stored URL needs correcting after the restore, run the matching command below. It removes the relevant WordPress filter for that command only. Replace the example URL with the value you recorded for that option before the restore.
>
> ```bash theme={null}
> wp eval 'remove_filter( "option_home", "_config_wp_home" ); update_option( "home", "https://destination.example" );'
> wp eval 'remove_filter( "option_siteurl", "_config_wp_siteurl" ); update_option( "siteurl", "https://destination.example/wordpress" );'
> ```
>
> Run the two inspection commands again and check links on the restored site. These commands leave the constants in `wp-config.php` in effect.
>
> ### If the Restore Fails
>
> The command prints the error message and error code. If the site is left in maintenance mode, the command shows a warning. After investigating, delete the `.maintenance` file in the WordPress root directory to bring the site back online.

***

## Example Workflows

### Daily Sync Script

Create a script to sync all sites and check for updates:

```bash theme={null}
#!/bin/bash
# daily-mainwp-sync.sh

# Sync all sites
wp mainwp sites --sync-sites

# Check for updates
wp mainwp updates --available-updates

# Check site status
wp mainwp sites --check-sites
```

### Get Site Overview

```bash theme={null}
# Get all connected sites
wp mainwp sites --connected-sites

# For each site, get available updates
wp mainwp site --site-available-updates 1
wp mainwp site --site-available-updates 2
```

> [!NOTE]
>
> Replace site IDs with your actual child site IDs. You can find site IDs by running `wp mainwp sites --all-sites`.

***

## Self-Check Checklist

* [ ] WP-CLI installed on the MainWP Dashboard server
* [ ] MainWP Dashboard v4.1.3 or later
* [ ] Test basic command: `wp mainwp sites --all-sites`
* [ ] Site IDs identified for site-specific commands
* [ ] WP-CLI available on the server hosting the child site before using `wp mainwp-child`
* [ ] Unique Security ID configured before disabling password authentication
* [ ] Separate backup covers the files or database affected by `wp mainwp-child backup restore`

***

## Related Resources

* [SureTriggers Automation](https://docs.mainwp.com/advanced/integrations/automate-your-mainwp-workflow-with-suretriggers.md) - Visual workflow automation
* [REST API Overview](https://docs.mainwp.com/api-reference/rest-api/overview.md) - API-based automation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.