Skip to content
Free test

Upgrade, and move to PostgreSQL

In development. Not available. Packages are not yet published for download.

Applies to: Reach 0.1.1, built from commit 08df4b0. There is no release.

Copied word for word from docs/admin/upgrade-and-migrate.md in the private Reach repository, commit 08df4b0, 21 November 2026.

The guide: Upgrading Reach Server, and moving from SQLite to PostgreSQL

Reach is in development. Its packages are not published.

For the administrator of a Reach server. Everything here was run on a Mac with PostgreSQL 17.12 and in the project's automated tests (SQLite and PostgreSQL 17.12). A separate tester on our team also ran migrate-store from SQLite to PostgreSQL 17.12 in a Rocky Linux 9 virtual machine, on an earlier development build (before version numbering was fixed); that has not been repeated on the current build.

Upgrade#

Upgrade the server before the agents (the Reach agent, the read-only program on each machine). A newer agent can send things an older server does not know yet (for example a user whose latest snapshot could not be read, snapshot_unreadable, or the matching check-in fields), and the older server refuses that report or check-in until it is upgraded.

Stop the server first (sudo systemctl stop reach-server), then upgrade, migrate and start it again. If you upgrade the package while the server is running, the package checks the database with the new version (reach-server migrate --dry-run, which changes nothing): when no migration is needed it restarts the server onto the new version; when one is needed, or the check fails, it stops the server and prints what to run, rather than restart it onto a database it would refuse every 10 seconds.

  1. Install the new package or binary: sudo dnf upgrade <folder>/reach-server-<version>-<build>.<arch>.rpm. Each build has its own build number in the package name, so a newer build of the same version is an upgrade too. (Builds made before 0.1.1 all had version 0.1.0 and build number 1, so dnf saw no difference between them and needed dnf reinstall.) Upgrade the agents after the server (below): a server accepts no agent older than its floor, 0.1.1 for this version (release notes). The server refuses to start when the database schema does not match it (run "reach-server migrate" first).
  2. Run the migration.
    • SQLite: sudo -u reach-server /usr/bin/reach-server migrate. It first copies the database to a backups folder next to it (mode 0600) and then applies the pending migrations, each in its own transaction. --dry-run says what would happen.
    • PostgreSQL: take your own backup with pg_dump, run as the service account, as in server administration, then sudo -u reach-server /usr/bin/reach-server migrate --backup-done. Without --backup-done the command refuses and changes nothing.
  3. Start the server: sudo systemctl start reach-server. migrate answers "The database is up to date" when there is nothing to do, so running it on every upgrade is safe. A new server can refuse older agents (version_unsupported); after starting it, open the Machines page: a machine whose agent was refused shows "Refused: agent too old (0.1.0), needs 0.1.1 or newer" under its agent version, until it checks in again with an accepted version.

Then upgrade the agents#

The order is: upgrade the server, run migrate, start the server, then upgrade the agents.

On each machine: sudo dnf upgrade <folder>/reach-agent-<version>-<build>.<arch>.rpm (Ubuntu: sudo apt install ./reach-agent_<version>-<build>_<arch>.deb). The package restarts a running agent service once, onto the new version, and keeps its identity.

After upgrading the server, an agent it had refused as newer than itself comes back by itself within six hours, or at once with sudo systemctl restart reach-agent.

An agent still older than the server's floor is refused at every check-in and sends nothing until it is upgraded (seen on our lab's Rocky Linux 9 server when it went from 0.1.0 to 0.1.1 with a 0.1.0 agent):

  • sudo reach-agent status --machine shows Last failed check-in: <time> (version_unsupported), then "The server does not accept this agent's version. Retrying will not help: upgrade the older of the two, the agent or the server.", and the time of its next attempt (six hours later).
  • sudo journalctl -u reach-agent shows the warning check-in failed (version_unsupported); backing off.

After the agent is upgraded its service starts on the new version, drops the old refusal from status and checks in at once. The server takes one check-in per machine every 240 seconds; if the machine checked in less than four minutes earlier, the server asks it to wait for the rest of that time. The journal then shows check-in refused; waiting for the time the server asked with code=rate_limited and the wait in seconds, and status shows rate_limited with the time of the next attempt. Nothing needs doing: it checks in at that time. (Seen once in our own lab, on a Rocky Linux 9.8 virtual machine during the agent upgrade from 0.1.1-281 to 0.1.1-316: a rate_limited warning and the wait, then the report delivered; the rest is from the code and its tests.)

Migrations only go forward. Downgrading is restoring the backup taken before the upgrade, and starting the older server on it. This release's schema is 12 (reach-server version prints it; a test keeps this number equal to the code). Schema 2 added first_seen_at and gone_at to tools and MCP servers, and three filter columns to the change log; existing rows were filled in (first seen is the time they were last observed; events got their product and host from their saved text). Schema 7 adds two columns to the machines: the hash of the last report and the time the machine last confirmed it unchanged; no row is rewritten, and a machine is asked for one report at its first check-in afterwards. Schema 8 adds one column to each machine's users: the time a snapshot that could not be refreshed was collected; it is empty for every existing row. Schema 9 adds two columns to the machines: the agent version the server last refused and when; they are empty for every existing row and are cleared when the machine is next accepted. Schema 10 adds two columns to the machines: since when the agent has said at each check-in that it cannot read its saved data, and how many users' saved data it could not read at its last check-in; they are empty (and 0) for every existing row and are set by the next check-in. Schema 11 adds a table of issued Statements (each one's exact bytes, signature, number and the key that signed it); it starts empty. Schema 12 adds one column to the machines: what the latest report said about AI used in the browser (under which setting of the switch it read the DNS cache, or why it named none). It is empty for every existing row, so with the switch on, before or after the upgrade, no machine counts as read until a report made under the setting in force arrives: the machine page says "No report made under the setting in force has arrived from this machine yet. It has been asked for one.", and each machine is asked for a report at its next check-in. An agent older than this server never names a setting and stays "not read" until it is upgraded.

Move from SQLite to PostgreSQL#

reach-server migrate-store copies every table of a stopped SQLite server into a new, empty PostgreSQL database in one transaction, then checks the row count of each table.

  1. Create an empty PostgreSQL database and a role that owns it. Put the postgres:// address in a file with mode 0600 (see Use PostgreSQL).
  2. Stop the server: systemctl stop reach-server. The command refuses to run while something answers on the server's listen address.
  3. Make sure the SQLite database is at the current schema (sudo -u reach-server /usr/bin/reach-server migrate).
  4. Copy: sudo -u reach-server /usr/bin/reach-server migrate-store --config /etc/reach-server/server.toml --to postgres --url-file /etc/reach-server/pg-url It prints one line per table. If anything fails the PostgreSQL database is left empty and the SQLite file is unchanged. A second run refuses, because the destination is no longer empty.
  5. Edit server.toml: under [database] set driver = "postgres" and url_file = "/etc/reach-server/pg-url", and remove path. Start the server and open the console.

Going back is leaving step 5 undone: the SQLite file was not touched, and anything the server wrote to PostgreSQL after the switch stays there. The key-encryption key does not change; sealed values (the instance key, each organisation's (tenant's) salts, token secrets) are copied as they are and open with the same key.

Not covered. The copy writes row by row; it was measured only on small databases. Sessions are copied too, so people stay signed in. The command does not copy schema_migrations (the new database recorded its own migrations). A PostgreSQL database cannot be moved back to SQLite.