Upgrade and back up
Upgrade
Section titled “Upgrade”The changelog lists the releases. It marks the node releases that are important for security.
The node never updates itself. About every six hours, an enrolled node asks
the cloud for the newest release. If the node runs an older release, its
status page shows Update available, with both versions. /api/status
then has versions.latest and versions.update_available: true.
Development builds and standalone nodes show no update notice.
Verify the image
Section titled “Verify the image”opdns signs every release image with cosign. Each image also carries a signed SBOM (the list of software inside it, in SPDX format) and SLSA build provenance (a record of how and from what it was built). Verify the image that you will run, by tag or by the digest in the release notes. The digest is the better choice:
cosign verify \ --certificate-identity https://github.com/operomtl/opdns/.github/workflows/release.yml@refs/heads/main \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ ghcr.io/operomtl/opdns-node:<version>gh attestation verify oci://ghcr.io/operomtl/opdns-node:<version> --repo operomtl/opdnsThe two --certificate-… values name the signer. The signer is the
release build of opdns, which runs on GitHub Actions from the main branch
of the opdns source repository. The signature is “keyless”: there is no
opdns key to download. The certificate records that identity, and cosign
compares it with the public Sigstore transparency log. Copy both values
exactly as shown.
cosign verify prints the claims of the signature and exits 0. It fails
for an image that the release build of opdns did not build and sign.
cosign verify-attestation --type spdxjson, with the same two flags,
verifies the SBOM. gh attestation verify (the GitHub CLI) verifies the
build provenance. The floating tags (v1.2, v1, latest) point at a
signed release digest, so they verify in the same way. To see the
reference on the status page, run the image by digest
(ghcr.io/operomtl/opdns-node:<version>@sha256:…). Then set
OPDNS_IMAGE to that reference.
Static binaries come with a SHA256SUMS file on the
release. Verify them with
sha256sum -c SHA256SUMS --ignore-missing
(Install the static binary). The
binaries are not signed yet.
To upgrade a container, pull the new version and create the container again. The volume keeps the identity, the last profile and lists, and the logs.
docker pull ghcr.io/operomtl/opdns-node:<version>docker rm -f opdns-nodedocker run ... # same command, new tag# or, with Compose: edit the tag, thendocker compose up -dThe image runs as the unprivileged user opdns, with the fixed ids
10001:10001. The volume therefore stays readable across upgrades. The root
file system of the image can be read-only, because the node writes only to
the volume.
To upgrade a binary install, follow these steps:
- Download and verify the new binary, as on Install the static binary.
- Replace
/usr/local/bin/opdns-node. - If a release changes the unit, replace your unit with the new
unit file. Then run
sudo systemctl daemon-reload. - Run
sudo systemctl restart opdns-node.
The systemd unit gives the port-binding capability itself, so you do not have to do more. Upgrade Unbound with your package manager. The container ships its own pinned Unbound. The node refuses to start with an Unbound older than 1.17.0. The error names the version that it found.
A certificate renewal needs no restart. The node reloads renewed files by itself (certificates). Some configuration keys also need no restart (reload without a restart).
On SIGTERM, the node stops cleanly. It drains its listeners, flushes
pending log records, closes the link and stops Unbound.
What an upgrade changes on disk
Section titled “What an upgrade changes on disk”- The log database: when a release changes the schema of
logs.sqlite, the node first copies the database tobackups/pre-v<N>.dbin the data directory. N is the old schema version. If the disk has no space for the copy, the node skips it and logs a warning. Then the node migrates the database in one transaction. A failed migration leaves the database as it was. The node refuses a database written by a newer release, and names thepre-v<N>.dbcopy to go back to. A downgrade therefore never misreads the database. - The configuration file: its
versionkey gives its format (1 today). The node migrates an older file when it loads it. It refuses a newer one (Configuration). - A corrupt database: if the node finds the database corrupt at start (for
example after a power cut), it moves it to
backups/corrupt-<time>.dband creates a new one. The local page tells you this. DNS is not affected.
Back up
Section titled “Back up”opdns-node backup writes one archive of all the data that the node
cannot fetch again. You can safely run it while the node runs.
sudo -u opdns opdns-node backup /var/backups/opdns-node.tar.gz# container:docker exec opdns-node opdns-node backup /var/lib/opdns/opdns-node-backup.tar.gzdocker cp opdns-node:/var/lib/opdns/opdns-node-backup.tar.gz .The archive is a .tar.gz, written with mode 0600. The command refuses to
overwrite an existing file. The archive holds:
| From the data directory | Holds |
|---|---|
node.json |
node id and node token |
profile.json |
the last good profile |
lists_keys.json |
list signing keys learned from the cloud or latest.json |
profile_keys.json |
profile signing keys learned from the cloud (Profile signing keys) |
lists_announced.json |
the last list version the cloud announced |
secrets/ |
the local API token |
logs.sqlite |
a consistent snapshot of the query log database |
The archive does not hold lists/ and unbound/, because the node
downloads or generates them again. It also does not hold backups/ and the
lock file.
Do not copy logs.sqlite by hand while the node runs. Recent rows can
still be in its -wal file. Use opdns-node backup, or stop the node
first.
Restore and move a node
Section titled “Restore and move a node”To move a node to a new host, or to a new container volume:
-
Stop the old node, and take a new backup of it.
-
Install the node on the new host without starting it.
-
Restore into its (empty) data directory, then start it:
Terminal window sudo -u opdns opdns-node restore /var/backups/opdns-node.tar.gzsudo systemctl start opdns-node
The node starts enrolled, with its profile, its list and profile keys, and its logs. If the node token rotated after you took the backup, the restored token is no longer valid. In that case, enroll the new host again instead.
restore takes the lock of the data directory, so it fails while a node
runs on that directory. It refuses a directory that already holds an
identity or a log database, unless you give --force. It accepts only the
files that backup writes. Before it moves anything into place, it makes
sure that the database is not damaged.
Only one node can use an identity at a time. If a second copy runs at the same time, it replaces the link session of the first one. Without an archive, enroll the new host again instead (Enroll).
The data directory
Section titled “The data directory”The default data directory is /var/lib/opdns, created with mode 0700.
| Path | Holds | In the backup |
|---|---|---|
node.json |
node id and node token (secret, 0600) | yes |
profile.json |
last good profile | yes |
lists/ |
last good list artifacts | no (re-fetched) |
lists_keys.json |
list signing keys learned from the cloud or latest.json |
yes |
profile_keys.json |
profile signing keys learned from the cloud, removed when you unenroll the node | yes |
lists_announced.json |
the last list version the cloud announced, so a restart still tells a rollback from an old notice | yes |
operator_blocks.json, operator_sources.json |
the last operator blocks the cloud sent, enforced offline | no (re-sent with the next profile pull) |
archive/ |
standalone-profile-<time>.json: a standalone profile uploaded at enrollment |
no |
secrets/ |
api_token, the generated local API token (secret, 0600, standalone mode), and api_token.shown after the page shows the token |
yes |
logs.sqlite (+ -wal, -shm) |
query logs | yes, as a snapshot |
backups/ |
pre-v<N>.db copies taken before a schema migration, corrupt-<time>.db databases moved aside |
no |
unbound/ |
generated configuration and root key | no |
The node refuses to start while every user of the host can read
node.json or a file under secrets/. Anyone who can read them can act as
the node. The node writes them with mode 0600. A less strict mode comes
from a copy or a restore by hand. The error names the file and the fix:
sudo chmod 600 /var/lib/opdns/node.json /var/lib/opdns/secrets/*If the group of a file can read it, but not every user, the node logs a warning.