
# Back up and restore a Sovrium SQLite database

On the SQLite default, all of an app's data lives in one database file inside `SOVRIUM_DATA_DIR` (default `./.sovrium/database.db`). Backing it up is copying one file — but do it consistently, because SQLite runs in WAL mode with side files.

## Take a consistent backup

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

```bash
sqlite3 .sovrium/database.db ".backup '/backups/app-$(date +%F).db'"
```

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

## Restore

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

```bash
sovrium stop        # or systemctl stop / docker stop
cp /backups/app-2026-07-20.db .sovrium/database.db
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

- [Database Infrastructure](/en/docs/database-infrastructure) — the SQLite defaults and `SOVRIUM_DATA_DIR`.
- [Connect Sovrium to PostgreSQL](/en/docs/integrate-postgres) — when you outgrow single-file backups.
- [GDPR & Privacy](/en/docs/gdpr-privacy) — data export and erasure obligations.
