We’ve been running on the default SQLite database and want to move to our PostgreSQL cluster so it’s covered by our normal DB backups. Is there a migration tool? And separately, what exactly should we be backing up today?
Yes. PostgreSQL 13+, MySQL 8.0+ (MariaDB 10.6+) and SQL Server 2019+ are supported, and there’s a built-in copy tool. It’s one way only: SQLite to a network engine.
The short version:
- Stop the service.
- Create an empty database and an owning user. Don’t start ZoneRails against it first, because a boot seeds roles and the admin, and the copy then refuses with
TARGET_NOT_EMPTY. - Replace the
databaseblock inconfig.json, leavingencryption.keyexactly as it is.config.example.postgres.jsonships beside the server. - Run the copy with the server’s own Node.js, as the service account. On Linux this ends with
server.js --copy-database --from /var/lib/zonerails/zonerails.db; the docs have the full command per platform. - Start the service and confirm
curl -s http://localhost:3000/api/healthshows"client": "postgres".
Keep the SQLite file until the new database has been backed up at least once.
Backups: back up the data directory and the database together. config.json carries the JWT secret and the encryption key; lose it and every stored credential is unreadable. Protect that backup like the server itself.