Skip to main content
View as Markdown

Back up and restore a Sovrium SQLite database

On the SQLite default, an app's rows live in one database file inside SOVRIUM_DATA_DIR (default ./.sovrium/database.db). Copying it is most of a backup — but do it consistently, because SQLite runs in WAL mode with side files, and copy the encryption key beside it.

Take a consistent backup

Use SQLite's online backup so an in-flight write can't corrupt the copy (no downtime needed):

>_ terminal
sqlite3 .sovrium/database.db ".backup '/backups/app-$(date +%F).db'"
cp .sovrium/encryption-key /backups/encryption-key      # unless SOVRIUM_ENCRYPTION_KEY is set in the environment

For a whole-directory snapshot (database, key and uploaded files), stop the server first, then copy SOVRIUM_DATA_DIR in full.

Restore

Stop the app, replace the database file, and start again:

>_ terminal
sovrium stop        # or systemctl stop / docker stop
cp /backups/app-2026-07-20.db .sovrium/database.db
cp /backups/encryption-key .sovrium/encryption-key      # only if the original key is gone
rm -f .sovrium/database.db-wal .sovrium/database.db-shm
sovrium start app.ts

Verify

The startup summary reports the SQLite database, and your records are back. Automate the backup command with cron for off-site copies.

Next

Last updated September 1, 2026

This documentation was written with AI, so errors or outdated content are possible. Sovrium is in beta. Contributions and corrections are welcome.

Built with Sovrium