Backing Up and Restoring
A new Sicura Console container upgrades its databases when it starts, and an upgraded database can't be downgraded. The only way back to the previous release is a backup taken before the upgrade. Take one before every upgrade, and keep it until you've confirmed the upgraded Console works.
This page covers both Console images: the Sicura Console (tagged <version>-rails) and the Classic Console (tagged <version> or latest). Where they differ, the steps say so.
Use Your Own Database Backup¶
If you already back up your PostgreSQL databases, use that. A storage-level snapshot, a managed-database snapshot, or an existing pg_dump job are all good backups, as long as:
- It covers every database listed in What to Back Up.
- It is taken while the Console is stopped. A backup taken while the Console is running can capture a half-finished operation. It restores without error, but some of its records point at data that isn't there.
- You have already tested restoring it.
Record the running image and stop the Console as described below, take your backup, and continue with the upgrade. The rest of this page is a manual procedure for when you have no backup of your own.
Manual Backup¶
These steps use pg_dump and pg_restore from the official postgres container image, so you don't need a PostgreSQL client installed on the host. Neither Console image includes one.
IMPORTANT: These steps work for the deployments described in this documentation, but they can't account for every PostgreSQL setup. Before you upgrade, make sure that you can restore the backup you took.
What to Back Up¶
Each image keeps its data in PostgreSQL, but in a different number of databases. Use the names from your container configuration.
- Sicura Console — two databases:
- The main database, named by
DB_DATABASE. It includes every tenant's data. - The job-queue database, named by
DB_QUEUE_DATABASE(defaultsicura_console_production_queue). It is onDB_QUEUE_HOSTif you set one, otherwise onDB_HOST.
- The main database, named by
- Classic Console — one database, named by
DB_DATABASE, or bymain.databaseinsicura-console.yamlif you set the connection there.
The Sicura Console also uses a cache database (DB_CACHE_DATABASE, default sicura_console_production_cache). It holds nothing that needs to be kept, so it isn't backed up; a restore empties it instead.
Besides the databases, a rollback needs the configuration the previous container ran with. Copy these along with the backup, somewhere only administrators can read:
- The container's run definition: the
docker runcommand, compose file or Quadlet unit, including every environment variable. It holds secrets such asSECRET_KEY_BASEand the database password. - The configuration directory you mount into the container, such as
/etc/sicura/config, withsicura-console.yaml(Classic Console). - Your Sicura license key.
- The TLS certificates and keys the Console and its reverse proxy use.
Record the Running Image¶
Create a directory for this backup, then record which image the current container runs. The dumps hold every tenant's data, so the directory is created readable only by you:
BACKUP_DIR=/path/to/backups/sicura-console-$(date +%Y%m%d-%H%M%S)
mkdir -p -m 700 "$BACKUP_DIR"
docker inspect --format '{{.Config.Image}}' sicura-console | tee "$BACKUP_DIR/image.txt"
docker image inspect --format '{{join .RepoDigests "\n"}}' \
"$(docker inspect --format '{{.Image}}' sicura-console)" | tee -a "$BACKUP_DIR/image.txt"
The first line of image.txt is the image reference, such as registry.customers.sicura.us/products/sicura-console:2026.10.0-rails. The next is its digest, registry.customers.sicura.us/products/sicura-console@sha256:<digest>. To roll back, you start the container from one of them.
If the container runs the latest tag, use the digest: latest moves to the new release, so it can't take you back.
Stop the Console¶
Stop the container, so that nothing writes to the databases while you back them up:
Leave the container in place until the backup is verified. If you need to call off the upgrade, docker start sicura-console starts it again. A container started with --rm is removed when it stops; start it again with your saved run definition instead.
Connect to PostgreSQL¶
The commands below run every PostgreSQL client command in a throwaway postgres container, through a shell function. Set it up first:
-
Set the connection variables. Use the values from your container configuration:
DB_HOST,DB_PORTandDB_USER:PG_CLIENT=docker.io/library/postgres:17 export PGHOST=<db-host> PGPORT=5432 PGUSER=sicura_console PGSSLMODE=require read -rsp 'Password for the Console database user: ' PGPASSWORD && echo export PGPASSWORDThe password is read from the terminal, so it doesn't end up in your shell history or in a process listing.
Set
PGSSLMODEto the Console'sDB_SSLMODE. If you never setDB_SSLMODE, userequire, ordisableif the server doesn't accept TLS connections. See Encrypting the Database Connection. -
Define the
pgfunction:pg() { docker run --rm -i --network host \ -e PGHOST -e PGPORT -e PGUSER -e PGPASSWORD -e PGSSLMODE \ "$PG_CLIENT" "$@" }If the Console verifies the server's certificate (
DB_SSLMODE=verify-caorverify-full), give the client the same CA certificate. SetPGSSLMODEto match, and define the function this way instead:pg() { docker run --rm -i --network host \ -e PGHOST -e PGPORT -e PGUSER -e PGPASSWORD -e PGSSLMODE \ -e PGSSLROOTCERT=/ca.pem -v /path/to/ca.pem:/ca.pem:ro,z \ "$PG_CLIENT" "$@" }--network hostlets the client reach anything the host can reach, including a PostgreSQL container that publishes its port on the host. If PostgreSQL is reachable only on a container network, replace--network hostwith--network <network-name>, and setPGHOSTto the name the Console uses for it. If it runs in a Podman pod, as in the Reference Deployment with SSL Termination, replace--network hostwith--pod <pod-name>and setPGHOST=localhost. -
Check the connection, and find the server's version:
The client must have the same major version as the server: the number before the first dot. If the server isn't version 17, set
PG_CLIENTto match, for examplePG_CLIENT=docker.io/library/postgres:16.
Back Up the Databases¶
Dump each database to the backup directory. Each command prints its exit status.
Sicura Console
pg pg_dump -Fc -d sicura_console > "$BACKUP_DIR/sicura_console.dump"; echo "exit status $?"
pg pg_dump -Fc -d sicura_console_production_queue > "$BACKUP_DIR/sicura_console_production_queue.dump"; echo "exit status $?"
If the job-queue database is on its own server (DB_QUEUE_HOST), name that server for its dump: start the second line with PGHOST=<queue-db-host> pg pg_dump.
Classic Console
Verify the Backup¶
Continue only if every dump printed exit status 0. Any other status means the dump is incomplete; the error above it says why. Fix the cause and run the dump again.
Then check that each file can be read back in full:
for f in "$BACKUP_DIR"/*.dump; do
pg pg_restore -f /dev/null < "$f" && echo "OK $f" || echo "FAILED $f"
done
This reads every part of each dump without writing it anywhere, so a file that was cut off partway through reports FAILED.
Every file must report OK. Your backup is now complete: return to Upgrades and continue with the next step.
Restoring a Backup¶
Restore the backup if an upgrade fails, or if you need to go back to the previous release.
Before You Restore¶
- Sicura Console — Start the previous release with exactly the
SECRET_KEY_BASEit had when you took the backup, and the sameDEVISE_JWT_SECRET_KEYif you set one. The Console encrypts sensitive database fields with keys derived from them. Under any other key that data can't be read, and every login session and API token stops working. - A different PostgreSQL server — A backup doesn't include database users. If you restore onto a server other than the one you backed up, create the Console's database user there first.
Restore the Databases¶
-
Stop and remove the new container:
-
Set up the connection as in Connect to PostgreSQL, if this is a new shell, and set
BACKUP_DIRto the backup's directory. -
Drop each backed-up database and create it again, empty, owned by the Console's database user. This needs a PostgreSQL superuser, such as
postgres:read -rsp 'Password for the PostgreSQL superuser: ' SUPERUSER_PASSWORD && echo PGUSER=postgres PGPASSWORD="$SUPERUSER_PASSWORD" pg psql -d template1 -v ON_ERROR_STOP=1 \ -c 'DROP DATABASE sicura_console' \ -c 'CREATE DATABASE sicura_console OWNER sicura_console'Restoring over the upgraded database isn't enough. A restore only replaces what the backup contains, so tables the upgrade added would remain, and the next upgrade would fail on them.
For the Sicura Console, do the same for the job-queue database (with
PGHOST=<queue-db-host>if it is on its own server): -
Sicura Console: empty the cache database the same way (with
PGHOST=<cache-db-host>if it is on its own server). The new release has already upgraded it, and the previous release sets it up again when it starts: -
Restore each dump into its empty database, as the Console's database user:
pg pg_restore --exit-on-error --single-transaction -d sicura_console \ < "$BACKUP_DIR/sicura_console.dump"; echo "exit status $?"For the Sicura Console, also restore the job-queue database (start the line with
PGHOST=<queue-db-host> pg pg_restoreif it is on its own server):pg pg_restore --exit-on-error --single-transaction -d sicura_console_production_queue \ < "$BACKUP_DIR/sicura_console_production_queue.dump"; echo "exit status $?"Each restore must print
exit status 0. A restore that fails changes nothing, so you can fix the cause and run it again.
Start the Previous Release¶
Start the Console from the image recorded in $BACKUP_DIR/image.txt, with the run definition and configuration you saved. Use the image reference, or the digest if the container ran latest. Docker pulls the image again if it is no longer on the host.
For example, if image.txt begins with registry.customers.sicura.us/products/sicura-console:2026.10.0-rails, run your saved docker run command with that image. Refer to Running the Console Container for the deployment options.
Once it is running, sign in and check that your nodes and reports are there. Agents registered before the backup keep their registration and reconnect on their own, which can take a few minutes; they don't need to be registered again.