Sovrain
  1. Documentation
  2. Self-hosting

How-to guide

Back up the data volume

Take a consistent copy of a Sovrain node's data volume and keep the master key apart from it.

This guide backs up everything a Sovrain node stores. All of it lives on one volume, mounted at /data in the container. In the examples the volume is sovrain-data and the container is sovrain. To bring a node back from such a copy, see Restore a node from a backup.

What you are backing up

The volume holds one SQLite database per organization with its password manager attachments, the node’s own database node.sqlite, the fingerprint of the master key and a few small marker and log files; every path is listed in Server configuration.

Two things to keep in mind:

  • The backup is useless without IDP_MEK. The keys inside the databases are wrapped under it, and Sovrain has no way to replace it with another key. Keep a copy of the key, but not next to the backup.
  • The backup holds personal data in readable form. The SQLite files are not encrypted; only keys and secrets inside them are. Protect the backup like the server itself.

Take a consistent copy

A copy of the files of a running node can catch a database in the middle of a write. Use one of these two ways.

Stop, copy, start. This is the simplest way. Nobody can sign in while the node is stopped.

  1. Stop the node, giving it time to finish requests in flight:

    docker stop --time 60 sovrain
    
  2. Copy the volume into an archive:

    docker run --rm -v sovrain-data:/data:ro -v /srv/backups:/backup debian:bookworm-slim \
      tar -C /data -czf /backup/sovrain-data-$(date +%Y%m%d-%H%M).tar.gz .
    
  3. Start the node again:

    docker start sovrain
    
  4. Move the archive off the server.

Snapshot the file system. If the volume lives on a file system that takes atomic snapshots, such as ZFS, Btrfs or LVM, snapshot it while the node runs and copy from the snapshot. Include the -journal files next to the databases, if there are any: SQLite uses them to roll back an unfinished write when the database is next opened. The snapshot must cover the whole volume at one instant.

Back up a single organization

An organization’s admins can also export their organization from the admin area and import it again; see Back up your organization. An export is not a replacement for the volume backup: it leaves out, among other things, everyone’s second factors, sessions and API access. What it contains: Export format.

What is stored where, and what is encrypted: About the security model. Why one key protects everything on the node: About running Sovrain yourself.