# Bash WP-CLI Update 9.1.0
Maintenance automation for a fleet of WordPress installations, driven by WP-CLI and
written in POSIX-friendly bash 5.1+.
[](https://github.com/paulmann/Bash_WP-CLI_Update/actions/workflows/ci.yml)
[](https://github.com/paulmann/Bash_WP-CLI_Update/releases)
[](LICENSE)
[](https://www.gnu.org/software/bash/)
[](https://www.npmjs.com/package/bash-wp-cli-update)
[**Installation**](#3-install) · [**Quick start**](#4-quick-start) · [**Modes**](#5-modes) · [**Configuration**](#8-configuration) · [**Wiki**](https://github.com/paulmann/Bash_WP-CLI_Update/wiki) · [**Documentation**](docs/README.md) · [**AGENTS.md**](AGENTS.md) · [**Releases**](https://github.com/paulmann/Bash_WP-CLI_Update/releases) · [**Issues**](https://github.com/paulmann/Bash_WP-CLI_Update/issues) · [**Security**](SECURITY.md)
> **For agents.** Start with [AGENTS.md](AGENTS.md): the ordered install, the
> verification order and the absolute do-nots. The
> [wiki](https://github.com/paulmann/Bash_WP-CLI_Update/wiki) carries the same
> material as a manual for a human reader.
One command updates core, plugins, themes, the database schema and cron events on
every site in a list, each one as the system user that owns it, with backups, a
JSON report, a change log and a restore path:
```bash
Bash_WP-CLI_Update.sh --full --backup db --jobs 4 --report /var/log/wp/report.json
```
* Version: **9.1.0** (finder 2.2.0)
* Requires: `bash >= 5.1`, GNU coreutils/findutils, WP-CLI, `root` (to switch into
site owners), one of `runuser` / `sudo` / `su`
* Optional: `flock`, `timeout` (or `perl`), `tar`, `gzip`, `nice`, `ionice`, `curl`,
`mail`
* Released under the **MIT** licence — see [LICENSE](LICENSE)
## Contents
- [1. What changed](#1-what-changed)
- [2. Safety model](#2-safety-model)
- [3. Install](#3-install)
- [4. Quick start](#4-quick-start)
- [5. Modes](#5-modes)
- [6. Selection and fleet control](#6-selection-and-fleet-control)
- [7. Backups and restore](#7-backups-and-restore)
- [8. Configuration](#8-configuration)
- [9. Output, reports and notifications](#9-output-reports-and-notifications)
- [10. Exit codes](#10-exit-codes)
- [11. Deploying it](#11-deploying-it)
- [12. Tests](#12-tests)
- [13. Upgrading from 6.x](#13-upgrading-from-6x)
- [14. Project layout](#14-project-layout)
- [15. Security: CVE-2026-119977](#15-security-cve-2026-119977)
- [16. License](#16-license)
---
## 1. What changed
Newest first. Each entry is what an operator notices; the full text of every release,
including the measured results, is in [CHANGELOG.md](CHANGELOG.md).
### 9.1.0 — a run can no longer claim success on a site it could not touch
Five defects from one production fleet, and the common shape is "the run said yes".
- **`--check` now proves the site loads.** It only looked at files, so a site whose
theme died with a parse error answered ✓ while every WP-CLI command on it failed.
Each site is probed with `wp core is-installed` as its owner; `--no-wp-probe`
(`WP_PROBE=false`) turns the probe off for a per-minute monitoring call.
- **An aborted upgrader is a failure, not a success.** A plugin hooking the upgrader
makes WP-CLI print `-1`, exit 0 and leave `.maintenance` behind; the site then serves
503 to visitors. The output is now read as "nothing was applied", the update is
retried once with `--skip-plugins --skip-themes`, and the leftover flag is cleared
after the site with a warning.
- **`--health` counts rows, not lines.** A site with `WP_DEBUG` printed deprecation
notices that were counted as pending plugins (20 where there were none) and
digit-stripped into the database size column.
- **The finder skips copies and clones.** `*.wp-YYYYMMDD`, `*.bak`, `*-old` are no
longer listed as sites, and a second tree on the same database and table prefix is
skipped with a warning naming the first (`--allow-shared-db` keeps both).
### 9.0.0 — the selective update path works on WP-CLI 2.12; the floor is bash 5.1
- **Fixed: `--only-active`, `--exclude-plugins`, `--hold-plugins`, `--exclude-themes`,
`--hold-themes` and `--plugin-manage` did nothing on WP-CLI 2.x.** They asked
`wp list` for a `slug` field that does not exist, so every site that used them
failed with “cannot enumerate plugins … nothing was updated”. A nightly `--full` run
with `EXCLUDE_PLUGINS` set updated nothing at all, and the exit code was the only
thing that said so. The slug now comes from `name` and the display name from `title`,
in one call; `--all` was never affected.
- **Fixed: mu-plugins and dropins were sent to `plugin update`.** They are loaded from
`wp-content` but are not installable packages, so asking to update one failed a site
that was perfectly healthy. Entries with status `must-use` or `dropin` are skipped and
the reason is logged.
- **Fixed: `--debug` aborted the run on a host with `SKIP_IF_NO_UPDATES=1`**
(`DBG: unbound variable`): two helpers that return a value on stdout captured their
own console line. That is the profile §11 recommends, so the combination was reachable
exactly where it hurt.
- **Changed: the minimum bash is 5.1** (was 4.2). Bash 4.2 ships only on CentOS 7, which
reached end of life in June 2024, and on distributions that stopped receiving updates
years ago; every distribution still supported in 2026 ships 5.1 or newer. The manager,
the finder, the secret scanner and `install.sh` refuse an older bash with exit 3 and
the version they found. **Hosts with bash 4.x (RHEL/Rocky/Alma 8) stay on 8.1.1** —
which does contain the selection bug above.
- Exclusion and holding match the slug **or** the display name, case- and
whitespace-insensitively, which is what this README has promised since 6.0.
### 8.1.1 — test-only patch
No manager, finder, mode, option, configuration key or exit code changed. The fake `wp`
in the fleet suite built its argv record from several `write()` calls, so concurrent
workers could merge two records into one line and the invocation count flaked (“the batch
stopped early”); the record is now a single write. The release exists because a flaky
gate is worse than no gate.
### 8.1.0 — CVE-aware, and the licence moves to MIT
- **`--security`** (read-only) compares every site's WordPress core version with the fixed
releases for [CVE-2026-119977](#15-security-cve-2026-119977) and exits 1 when a site is
exposed, so it can gate a pipeline.
- **`--harden`**, the **`--harden-upgrade-dir`** flag and the **`HARDEN_UPGRADE_DIR=1`**
key append a marked deny block for `wp-content/upgrade/` to each site's `.htaccess`
(Apache, LiteSpeed) and print the nginx directive, because nginx ignores `.htaccess`.
- **`--health`** gained a CVE column, and a core run that leaves a site below the fixed
release says so instead of reporting success.
- The licence is now **MIT**, so commercial use no longer needs a separate agreement.
### 8.0.2 — a patch on the merge
A configuration file that set a mode-restricted key — `SKIP_IF_NO_UPDATES`,
`HOLD_PLUGINS`, `EXCLUDE_THEMES` — made `--doctor`, `--check`, `--health` and every list
mode exit with a usage error, because those keys were validated without asking which mode
was running. The production profile in §11 sets `SKIP_IF_NO_UPDATES=1`, so a host
configured exactly as documented could not be diagnosed. The keys are now enforced only
when they are typed on the command line; from a file they are inert for modes that do not
use them.
### 8.0.1 — a patch on the merge
Replaced the `LICENSE` file — which still contained the GNU GPL v3 text while the README
and the scripts said PolyForm Noncommercial 1.0.0 — with the actual PolyForm text and a
copyright line, extended `.gitattributes` to the file types 8.0.0 introduced, and rewrote
`legacy/README.md` so it names the release and the tag each original is frozen at.
Upgrading is a file copy, as always.
### 8.0.0 — the merge
8.0.0 is the merge of the 5.x/6.x lines of work: the 5.0 monolith in `main`, the
`QWEN_Hybrid` refactor (6.2.0) and the `DeepSeek_Hybrid` refactor (6.1.0). The
three-way comparison, including what was deliberately **not** merged and why, is in
[docs/COMPARISON.md](docs/COMPARISON.md).
Why a major number: the `QWEN-Agent_Mode` branch shipped 7.0.1, a modular tree built
from `src/` fragments. This is a rebuild on the 6.2.0 lineage, not a patch on that tree,
so it does not claim to continue it. That branch keeps its own release and is tagged
`llm/QWEN-Agent_Mode`; nothing was deleted to make room for this version.
Highlights:
| Area | What is new |
|---|---|
| Read-only modes | `--health` (versions, pending updates, database size), `--secrets` (masked scan of `wp-config.php`), `--doctor` (host diagnosis), `--list-backups` |
| Restore | `--restore-db FILE --yes`: the missing half of "we take backups" |
| Fleet control | `--retry N`, `--retry-delay`, `--max-failures` (circuit breaker), `--run-timeout`, `--lock-wait`, `--skip-if-no-updates` |
| Production guards | `--min-free-mb` (refuse to dump onto a full disk), `--nice`, `--ionice`, `--backup-age-days`, `--backup-compress` |
| Observability | `--report FILE` (JSON run report with a change list), `--json-log`, `--notify URL`, `--mail-to`, `--completion bash\|zsh` |
| Policy | `--exclude-themes`, `--hold-plugins`, `--hold-themes` (a pin, not a filter) |
| Multisite | `--url` is derived from `WP_HOME`/`WP_SITEURL` in `wp-config.php`; `--no-url-detect` turns it off |
| Compatibility | 6.1-era config names (`WP_TIMEOUT`, `WP_CLI_BIN`, ...) are accepted with a warning; short forms `-C -T -L -k -u` added |
Everything 6.x did still works: the ten original modes, the `.no_wp_cli` opt-out
marker, the licence handoff that never puts a key in `argv`, data-only configuration,
and the 0/1/2/3/4 exit-code contract.
---
## 2. Safety model
The tool runs as root and changes live sites, so the rules are explicit:
1. **argv, never a string.** Every WP-CLI call is a bash array. Nothing is built by
string concatenation, nothing goes through `eval`, and `printf %q` is never used.
The user switch passes arguments as positional parameters, so a path with a quote
or a space cannot break anything.
2. **Configuration is data.** A config file is parsed as `KEY=VALUE` and is never
sourced. A line containing a shell metacharacter rejects the whole file (exit 4),
and a group- or world-writable config file is refused before it is read.
3. **The licence never becomes an argument.** It is written to a temporary file that
is readable by root and the site owner's group only, the child shell reads it at
run time, and the file is removed when the call returns. `ps` never shows it.
4. **A backup happens before anything is modified.** A failed backup stops the site
instead of silently continuing unprotected (`--fail-on never` relaxes that, on
purpose).
5. **Read-only means read-only.** `--health`, `--secrets`, `--list-plugins`,
`--verify`, `--list-backups` and `--check` take no backup, take no lock and write
nothing but log lines.
6. **Destructive modes are two-key.** `--restore-db` needs `--yes`, dumps the current
database first and runs `wp db check` afterwards.
7. **Exit codes are a contract**, and they are honoured: `2` for a usage error, `4`
for a config error — not a generic `1`.
---
## 3. Install
Three ways, same result. Pick one:
```bash
# 1. npm (any Linux with node 16+; the package is a delivery channel, the tool is bash)
npm install -g bash-wp-cli-update
# 2. the installer from the archive
curl -LO https://github.com/paulmann/Bash_WP-CLI_Update/releases/latest/download/bash-wp-cli-update-9.1.0.tar.gz
sudo ./install.sh --dry-run # show every step
sudo ./install.sh --systemd # does it, plus the nightly timer
```
The npm package installs two commands, `wp-cli-update` and `wp-find`, that exec the same
scripts; it does **not** install WP-CLI, and it does not run anything for you. The tool
still needs root at run time, because it switches into the owner of every site.
```bash
# 3. by hand
sudo apt-get install -y bash coreutils findutils gzip tar
# WP-CLI itself:
curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo chmod 755 /usr/local/bin/wp
# the project
sudo git clone https://github.com/paulmann/Bash_WP-CLI_Update.git /opt/wp-cli-update
sudo chmod 755 /opt/wp-cli-update/Bash_WP-CLI_Update.sh
sudo ln -sf /opt/wp-cli-update/Bash_WP-CLI_Update.sh /usr/local/bin/wp-cli-update
sudo ln -sf /opt/wp-cli-update/Find_WP_Senior.sh /usr/local/bin/wp-find
# directories the tool writes to
sudo install -d -m 755 /var/log/wp-cli-update /var/backups/wp-cli-update /var/lib/wp-cli-update
# configuration (root only: it can hold a licence)
sudo install -m 600 /opt/wp-cli-update/wp-cli-update.conf.example /etc/wp-cli-update.conf
sudo editor /etc/wp-cli-update.conf
# build the site list
sudo wp-find --output /var/lib/wp-cli-update/wp-found.txt /var/www /home
# verify before touching anything
sudo wp-cli-update --doctor
sudo wp-cli-update --check
```
The finder leaves out what is not a site to update: directories carrying the
`.no_wp_cli` marker, snapshot copies (`*.wp-YYYYMMDD`, `*.bak`, `*-old`), and a
second tree that points at the same database and table prefix as another root —
that last one is reported with the path of the root that won, and
`--allow-shared-db` keeps both when two trees on one database is really what you
mean. Read what it skipped: a count per reason is printed when anything is left
out, and `--verbose` names every case.
`--doctor` answers "why would a run fail before it starts": the wp binary, the user
switch, the tools, the paths, the free space, the config permissions and the policy
in force.
`--check` answers the same question per site, and it now asks WordPress itself: one
`wp core is-installed` per site, as the site owner, so a theme or plugin that kills the
bootstrap is reported instead of a ✓. On a large fleet that probe costs about a second
per site; for a probe that runs every minute pass `--no-wp-probe` (config
`WP_PROBE=false`), and keep the per-site answer for the check that runs after a change.
---
## 4. Quick start
```bash
# inventory: what would change, without changing it
wp-cli-update --health
# both spellings work for every option that takes a value
wp-cli-update --full --site=/var/www/example.com --backup=db --dry-run
# one site, dry run first
wp-cli-update --full --site /var/www/example.com --backup db --dry-run
wp-cli-update --full --site /var/www/example.com --backup db
# the whole fleet, four at a time, with a report and a retry
wp-cli-update --full --jobs 4 --backup db --report /var/log/wp-cli-update/run.json --retry 2
# nightly: skip the 90% of sites that are already current
wp-cli-update --full --skip-if-no-updates --backup db --min-free-mb 500 --notify https://hooks.example/ops
# a plugin that must stay pinned
wp-cli-update --plugins --hold-plugins woocommerce,elementor
# restore one database from last night's dump
wp-cli-update --list-backups --site /var/www/example.com
wp-cli-update --restore-db /var/backups/wp-cli-update/example.com/db-20261020-030000.sql --site /var/www/example.com --yes
```
---
## 5. Modes
Exactly one mode per run.
| Mode | Short | What it does | Mutating |
|---|---|---|---|
| `--full` | `-f` | core + plugins + themes + database schema + optimize/repair + cron (+ Astra if licensed) | yes |
| `--core` | `-c` | `core update`, `core update-db --skip-plugins` | yes |
| `--plugins` | `-p` | update all plugins, or the enumerated set with `--only-active`/`--exclude-plugins`/`--hold-plugins` | yes |
| `--themes` | `-t` | update all themes, or the enumerated set with `--exclude-themes`/`--hold-themes` | yes |
| `--db-optimize` | `-d` | `db optimize` then `db repair` | yes |
| `--db-fix` | `-x` | `db repair` | yes |
| `--cron` | `-r` | `cron event run --due-now` | yes |
| `--astra` | `-s` | Astra add-on update, activating the licence if needed | yes |
| `--list-plugins` | `-l` | plugin inventory as table, JSON, CSV or TSV | no |
| `--plugin-manage` | `-m` | activate / deactivate / delete one plugin (delete needs `--yes` or a terminal) | yes |
| `--verify` | | `core verify-checksums` and `plugin verify-checksums --all` | no |
| `--health` | | core version, pending plugin/theme updates, database size | no |
| `--secrets` | | secret constants in `wp-config.php` by name, permissions, stale copies | no |
| `--security` | | CVE-2026-119977 assessment: core version against the fixed releases; exit 1 when a site needs an update | no |
| `--list-backups` | | backup files per site, newest first | no |
| `--restore-db FILE` | | import FILE into the database (needs `--yes`) | yes |
| `--harden` | | append the `wp-content/upgrade/` deny block to each site's `.htaccess` and print the nginx directive | yes |
| `--check` | | environment plus every site in the list — each site is probed with `wp core is-installed` (`--no-wp-probe` skips it) | no |
| `--status` | | last run summary and log sizes | no |
| `--doctor` | | host diagnosis, no site list needed | no |
| `--completion SHELL` | | print a bash or zsh completion script | no |
| `--list-sites` | | the resolved site list and exit | no |
| `--list-modes` | | mode names, one per line (for shell completion) | no |
---
## 6. Selection and fleet control
| Option | Meaning |
|---|---|
| `-S, --site PATH` | operate on one site, overrides the site list |
| `--sites FILE` | site list, one absolute path per line (default: `