opnexus – the command-line tool
With opnexus you update OPNexus with one command, roll back when something goes wrong and back up the database – without hand-editing containers or the database.
Overview
opnexus is a Bash script for installations that run from ready-made release images. It sits next to the docker-compose.yml in the release bundle and knows these commands. status, update, rollback, backup and password are described in detail below; for the others the manual has what you need:
| Command | What it does |
|---|---|
opnexus status | Shows the version, the services and the database revision. |
opnexus update [VERSION] | Pulls new images, switches, waits for “healthy” and rolls back automatically if something fails. |
opnexus rollback | Undoes the last update, including the database when needed. |
opnexus backup | Writes a database backup right away. |
opnexus password [NAME] | Sets a new random password and shows it once. |
opnexus backup --full / opnexus restore FILE | A full backup of the database and all secrets in one encrypted file, and restoring it. |
opnexus migrate-host TARGET | Move to another server that already has OPNexus installed: stop the source, back up, restore at the target, verify. |
opnexus ha … | Set up and operate high availability (warm standby), e.g. ha prepare, ha init, ha status, ha promote, ha update. |
opnexus export / opnexus apply FILE | Configuration as code: export central objects as YAML; check a file and take it over into the drafts (--dry-run for CI). Never writes to a firewall. |
On Windows and macOS the script does not run directly (it needs Linux tools). Run it from its Docker image there, in the OPNexus folder: docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:/project" ghcr.io/opnexus-dev/opnexus-updater:latest opnexus status (PowerShell: ${PWD} instead of $PWD). Details in the guides for Windows and macOS.
Where the images come from and how to verify them
Source code, tags and release bundles are on GitHub; the finished images are in the GitHub Container Registry (GHCR). A second registry holds copies with identical digests as a fallback.
| What | Where |
|---|---|
| Source code, tags, changelog, manual | github.com/OPNexus-dev/OPNexus |
Release bundle (compose file, opnexus, cosign.pub) | GitHub Releases |
| Images (default, amd64 and arm64) | ghcr.io/opnexus-dev/opnexus-backend, -frontend, -proxy, -updater |
| Fallback registry, identical digests | git.opnexus.dev/opnexus/opnexus-… |
| Version tracks | 1.42.3 (fixed), 1.42, 1, latest |
Every image is built once, signed with cosign and then copied to the second registry with an identical digest: the same version has the same digest and signature in both registries. opnexus update verifies the signature before switching as soon as cosign is installed. By hand:
cosign verify --key cosign.pub --insecure-ignore-tlog=true ghcr.io/opnexus-dev/opnexus-backend:1.42.3This needs cosign 3 or newer. With cosign 2.x the message is no signatures found, even for a validly signed image: check cosign version first and update if it shows 2.x. If it shows 3.x and the message stays, the image has no valid signature, so do not use it. opnexus update stops with cosign 2.x without changing anything.
You will find the public key cosign.pub in the release bundle and in the repository. To use the second registry, set OPNEXUS_IMAGE_REPO=git.opnexus.dev/opnexus in your .env.
Requirements
- Docker with Compose v2 and Bash on the server.
- An installation from the release bundle (ready-made images from the registry). Your
.envcontainsOPNEXUS_IMAGE_REPO; the bundle already sets it. Without it the tool stops – it is not meant for local builds (usegit pull && docker compose up -d --buildthere). - Run it in the folder with
docker-compose.ymland.env, or from anywhere withOPNEXUS_DIR=/path/to/opnexus.
cd /opt/opnexus-1.42.3
./opnexus statusstatus
Shows what is running and, if there is one, the last update that can be rolled back.
$ ./opnexus status
Image-Repo: ghcr.io/opnexus-dev
OPNEXUS_VERSION: 1
Laufende Version: 1.42.3
DB-Revision: 0036
backend: healthy
frontend: healthy
proxy: runningOPNEXUS_VERSION is the “track” the installation follows: a fixed version (1.42.3), a minor track (1.42), a major track (1) or latest. The labels in the output are in German, the tool's output language.
update
./opnexus update # follow the track chosen in .env
./opnexus update 1.42.3 # fixed version
./opnexus update 1.42 # newest 1.42.xHow it runs, step by step:
- Read the state. If the backend is not running or does not answer, the tool stops – repair first, then update.
- Pull the images. Nothing changes on the running system meanwhile. If the pull fails, nothing was changed.
- Remember the old state (file
.opnexus-update-state) so a rollback knows where to go. - Switch.
OPNEXUS_VERSIONis set in.env, thendocker compose up -d --no-buildruns. If the new version needs a database migration, the backend backs the database up itself first (pre-upgrade-….dump). - Wait until backend, frontend and proxy are healthy (240 seconds at most).
- On failure the tool shows the backend log and rolls back automatically.
Read the changelog before updating. An update usually takes only the services' restart; the web interface is briefly unavailable.
rollback
./opnexus rollbackPuts the installation back to the state before the last update: onto exactly the image tag that was set before.
- If the update did not migrate the database, only the services are set back to the old version.
- If it did, the backup taken before the update is restored. Only a backup created after this update started is used, and it is checked for readability first. A safety copy of the current state (
pre-rollback-….dump) is written before; if restoring fails, the tool restores that copy. - Afterwards
OPNEXUS_VERSIONin.envis pinned to the old version. For the next attempt, name the target version again.
Important: log history and resource measurements are not part of the backups and are empty after a database rollback. Everything else – hosts, rules, users, audit history – is back to its state before the update. Only one step is rolled back (the last update).
backup
./opnexus backupWrites a backup as manual-<time>.dump into the Docker volume postgres_backups. The data of the two large tables (firewall logs and resource measurements) is deliberately left out, otherwise the dump would be huge; all settings and the change history are included. A companion container also writes automatic backups into the same volume on a regular basis.
docker compose exec postgres-backup ls -l /backupspassword
./opnexus password # set a new password for the admin
./opnexus password anna # for a specific user
./opnexus password --yes # without the confirmationSets a new random password, shows it once and ends all sessions of the account. Meant for a fresh install (the password generated on first start appears in the log only once) and for a forgotten admin password.
- If nobody has signed in yet there is no confirmation; otherwise the tool asks (without a terminal
--yesis required). - Without a name
ADMIN_USERNAMEis used; if that account does not exist and there is exactly one admin, that one. - Two-factor sign-in stays on; if the authenticator is lost as well, the command under “More help” does it.
Configuration
| Setting | Effect |
|---|---|
OPNEXUS_DIR | Folder with docker-compose.yml and .env, if not the script's own. |
OPNEXUS_UPDATE_TIMEOUT | Seconds to wait for “healthy” (default 240). |
OPNEXUS_NO_AUTO_ROLLBACK=1 | No automatic rollback after a failed update; the state stays for analysis, manually: opnexus rollback. |
.env: OPNEXUS_IMAGE_REPO, OPNEXUS_VERSION | Registry and track of the installation. |
.env: POSTGRES_USER, POSTGRES_DB, POSTGRES_PASSWORD | Database access for backup and rollback (default user and database: opnexus). |
Safeguards
- Pull first, then switch: a failed download changes nothing.
- Automatic fallback: if the new version does not become healthy, it is rolled back.
- Backup before the migration and a check before restoring: never overwritten with a too-old or broken backup.
- Safety copy of the state before a database rollback.
- Input checked: the version may only contain characters an image tag can have.
- Password not in the process list: the database password reaches the tools through the environment, not as an argument.
Troubleshooting
The tool prints its messages in German. The most common ones:
| Message | What to do |
|---|---|
| “OPNEXUS_IMAGE_REPO ist in .env nicht gesetzt” | The installation does not run from release images. Either switch to release images or update locally with git pull && docker compose up -d --build. |
| “Pull fehlgeschlagen — nichts wurde verändert” | Is the registry reachable? Does the version exist? Then simply try again. |
| “Backend läuft nicht oder antwortet nicht” | Repair first (docker compose logs backend), then update. |
| “Update nicht gesund geworden” | The backend log follows; the tool rolls back by itself. With OPNEXUS_NO_AUTO_ROLLBACK=1 the state stays for analysis. |
| “Kein Update-Zustand … nichts zurückzurollen” | A rollback only works after an opnexus update (it needs the state file that update created). |
| “Datenbank wurde migriert, aber es gibt kein pre-upgrade-Backup” | The backup before the migration is missing (for example because of SKIP_MIGRATION_BACKUP). The backend stays stopped; intervene manually. Your own opnexus backup helps in future. |
Limits
- Only for installations from release images (amd64 and arm64).
- A rollback goes back one step – to the state before the last update.
- After a database rollback, log history and measurements are empty.
- The tool manages the OPNexus installation, not your firewalls; it changes nothing there.
More help
If the only admin is locked out without an authenticator and without recovery codes, this command switches off two-factor sign-in for one account on the server (it needs shell access to the server):
docker compose exec backend python -m app.reset_2fa USERNAMEThe full guide is in the handbook and the README (section “Release images & CI”).