Backup, restore and upgrades

Back up the database regularly and the master key once, apart. Upgrades migrate forward only.

On this page

Keeping the master key is covered in the data directory and the master key.

Back up the database

To back up a running Studio, use SQLite’s online backup rather than copying the file. Data that is still only in the -wal file would be missing from a plain copy.

sh
sqlite3 .kervan-studio/studio.db ".backup 'studio-backup.db'"
# or: sqlite3 .kervan-studio/studio.db "VACUUM INTO 'studio-backup.db'"

If you copy files while Studio is stopped, copy studio.db together with any studio.db-wal and studio.db-shm next to it.

To restore, stop Studio, put the backup in place as studio.db (with no stale -wal or -shm files next to it), and start Studio with the master key that was current when the backup was made, or a newer one that lists it in KERVAN_STUDIO_PREVIOUS_MASTER_KEYS.

Upgrade

  1. Stop Studio and back up the database (see above).
  2. Update the code and rebuild: pnpm install --frozen-lockfile && pnpm build.
  3. Start Studio. Pending database migrations run at startup; if one fails, Studio does not start and reports which.

Migrations only move forward. An older Studio refuses to open a database a newer one has migrated, so going back to an older version means restoring the backup from step 1.