Databases and Migrations
Roster supports SQLite for standalone deployments and PostgreSQL for Enterprise deployments.
| Database | Editions | Deployment shape |
|---|---|---|
| SQLite | All | One Roster instance with durable /data |
| PostgreSQL 17 or 18 | Enterprise | One or more Roster instances |
Choose the database before creating the production deployment. Roster does not
include an automated SQLite-to-PostgreSQL data migration. Existing SQLite
installations can continue using the same /data volume. Follow the
Docker upgrade procedure
when changing the image version. A new PostgreSQL deployment starts with a
separate PostgreSQL database.
Use this page in the following order:
- Select SQLite or PostgreSQL before creating production data.
- For PostgreSQL, provision separate migration and runtime roles.
- Apply migrations before starting the new application version.
- Configure and test backups before accepting the deployment.
SQLite
Section titled “SQLite”Leave ROSTER_DATABASE_URL unset to use /data/roster.db, or set it to an
explicit SQLite file: URL:
ROSTER_DATABASE_URL=file:/data/roster.dbSQLite defaults to ROSTER_DATABASE_MIGRATION_MODE=auto, which applies pending
migrations before starting Roster. Use one Roster instance and mount /data on
durable storage.
PostgreSQL
Section titled “PostgreSQL”Enterprise deployments can use PostgreSQL by setting the runtime database URL and loading a valid Enterprise license:
ROSTER_DATABASE_URL=postgresql://roster:<password>@postgres.internal:5432/rosterROSTER_LICENSE_KEY=<enterprise-license-jwt>To distribute ordinary reads across PostgreSQL read replicas, add one or more comma-separated replica URLs:
ROSTER_DATABASE_REPLICA_URLS=postgresql://roster_reader:<password>@replica-a.internal:5432/roster,postgresql://roster_reader:<password>@replica-b.internal:5432/rosterWrites and transactions continue to use ROSTER_DATABASE_URL. Replica routing
is optional for standalone PostgreSQL and required in High
Availability.
PostgreSQL is not available in Free or Pro. See Licensing for edition behavior and license installation.
Provision the database and roles
Section titled “Provision the database and roles”Use a managed PostgreSQL 17 or 18 service for production. Create one database, a schema-owning migration role, a DML-only application role, and—when read replicas are used—a read-only role. Configure login passwords or certificate authentication through the database provider rather than storing credentials in this script.
Run the following as a PostgreSQL administrator, replacing the role and database names if your provider requires different names:
CREATE ROLE roster_migrator LOGIN;CREATE DATABASE roster OWNER roster_migrator;
\connect roster
CREATE ROLE roster_app LOGIN;CREATE ROLE roster_reader LOGIN;
GRANT CONNECT ON DATABASE roster TO roster_app, roster_reader;GRANT USAGE ON SCHEMA public TO roster_app, roster_reader;GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO roster_app;GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO roster_app;GRANT SELECT ON ALL TABLES IN SCHEMA public TO roster_reader;
ALTER DEFAULT PRIVILEGES FOR ROLE roster_migrator IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO roster_app;ALTER DEFAULT PRIVILEGES FOR ROLE roster_migrator IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO roster_app;ALTER DEFAULT PRIVILEGES FOR ROLE roster_migrator IN SCHEMA public GRANT SELECT ON TABLES TO roster_reader;The example intentionally does not place passwords in SQL text. Configure each
login through the managed-database console or, when using psql, run the
following commands and enter each generated password at the prompt:
\password roster_migrator\password roster_app\password roster_readerUse the database provider’s required TLS mode in every connection URL. Confirm that the migration and runtime credentials can connect from the network where their respective jobs will run before continuing.
Run the migration-only container with the roster_migrator writer URL. Run
Roster with the roster_app writer URL and use roster_reader URLs for
ROSTER_DATABASE_REPLICA_URLS. The runtime roles must not own the schema or
receive CREATE, ALTER, DROP, or TRUNCATE privileges.
After the first migration, verify the application role can read and write Roster tables but cannot create or alter tables. Repeat that verification after restoring a backup into a recovery environment.
Production database migrations
Section titled “Production database migrations”Production PostgreSQL defaults to ROSTER_DATABASE_MIGRATION_MODE=skip.
Apply migrations with one dedicated release job before starting or updating
Roster instances.
| Mode | Container behavior | Intended use |
|---|---|---|
only |
Applies pending migrations, then exits successfully | One migration job per production release |
skip |
Starts Roster without attempting a migration | Production PostgreSQL Roster instances |
auto |
Applies pending migrations, then starts Roster | SQLite and non-production environments |
For PostgreSQL, give the migration job a schema-owning database credential and
give Roster instances a separate DML-only credential. Store both sets of
credentials in your deployment secret manager or in protected mode-0600
environment files; do not place them directly in shell history.
A migration-only environment file contains only the primary database URL and migration mode:
ROSTER_DATABASE_URL=postgresql://roster_migrator:<password>@postgres.internal:5432/rosterROSTER_DATABASE_MIGRATION_MODE=onlySave it as /secure/roster-migration.env or provide the equivalent through a
one-off release job.
A complete runtime environment for a fresh PostgreSQL database is:
ROSTER_AUTH_URL=<your-roster-public-url>ROSTER_AUTH_SECRET=<generated-auth-secret>ROSTER_BOOTSTRAP_ADMIN_PASSWORD=<generated-strong-password>ROSTER_PROVIDER_SECRET_ENCRYPTION_KEY=<generated-provider-secret-encryption-key>ROSTER_LICENSE_KEY=<enterprise-license-jwt>ROSTER_DATABASE_URL=postgresql://roster_app:<password>@postgres.internal:5432/rosterROSTER_DATABASE_REPLICA_URLS=postgresql://roster_reader:<password>@replica.internal:5432/rosterROSTER_DATABASE_MIGRATION_MODE=skipSave these values as /secure/roster-runtime.env or provide the equivalent
through your hosting platform’s secret manager. Omit
ROSTER_DATABASE_REPLICA_URLS for a standalone single-primary runtime. An
existing database whose bootstrap administrator already exists does not need
ROSTER_BOOTSTRAP_ADMIN_PASSWORD.
This example starts a fresh deployment. Replace <target-version> with the
release tag you chose. The block stops at the first failing command. For an
existing container, use the standalone upgrade example.
( set -e # Protect local environment files before using them. chmod 600 /secure/roster-migration.env /secure/roster-runtime.env
roster_image="advantys/roster:<target-version>"
# 1. Run once with the schema-owning migration environment. docker run --rm \ --env-file /secure/roster-migration.env \ "$roster_image"
# 2. Start or roll out every Roster instance with the restricted runtime URL. docker run -d \ --name roster \ -p 3000:3000 \ --env-file /secure/roster-runtime.env \ "$roster_image")For a standalone PostgreSQL deployment that uses local CSV connector files or
other persistent runtime files, also mount a durable volume at /data. HA
deployments must use shared S3 or SFTP connector storage instead of local files.
The migration job always targets the primary and does not need runtime secrets,
the Enterprise license, or replica URLs. After the first successful sign-in,
confirm the bootstrap administrator exists and remove
ROSTER_BOOTSTRAP_ADMIN_PASSWORD from the runtime secret configuration.
The PostgreSQL migrator takes an advisory lock, so an accidentally overlapping migration job waits instead of modifying the schema concurrently. The lock is a safety net, not a replacement for a single-owner release job. If the migration job fails, do not start the new application version; inspect the migration job logs and database state first.
For a multi-instance deployment with database failover, continue with High Availability.
Upgrade an existing standalone PostgreSQL deployment
Section titled “Upgrade an existing standalone PostgreSQL deployment”Follow the Docker upgrade procedure
to record settings, pause traffic, stop the old instance, and back up PostgreSQL
and /data before migration. This example assumes one existing container. Set
the name, network, published port, restart policy, volume, and environment file
paths to match your deployment. If it has no local volume, omit the mount. If
you manage the deployment with Compose or another orchestrator, reuse that
definition and change only the image.
roster_container=rosterroster_image="advantys/roster:<target-version>"roster_network=roster-networkroster_port="3000:3000"roster_restart=unless-stoppedroster_volume=roster_datamigration_env=/secure/roster-migration.envruntime_env=/secure/roster-runtime.env
create_roster_replacement() ( set -e replacement_id="$(docker create \ --name "$roster_container" \ --network "$roster_network" \ --restart "$roster_restart" \ -p "$roster_port" \ -v "$roster_volume:/data" \ --env-file "$runtime_env" \ "$roster_image")" || exit 1
if ! docker start "$replacement_id"; then if ! docker rm "$replacement_id" >/dev/null; then printf >&2 'Could not remove the failed replacement %s. Inspect that ID before retrying.\n' "$replacement_id" fi exit 1 fi)
( set -e docker pull "$roster_image" previous_id="$(docker inspect --format '{{.Id}}' "$roster_container")" if [ "$(docker inspect --format '{{.State.Status}}' "$previous_id")" != exited ]; then printf >&2 'Stop the previous container before running the migration.\n' exit 1 fi
if docker run --rm --network "$roster_network" \ --env-file "$migration_env" "$roster_image"; then printf 'Migration completed. Replacing the stopped container.\n' else printf >&2 'Migration failed. The previous container was not removed.\n' exit 1 fi
if ! docker rm "$previous_id" >/dev/null; then printf >&2 'Migration completed, but removal of the previous container failed. Check %s.\n' "$previous_id" exit 1 fi
if ! create_roster_replacement; then printf >&2 'Migration completed, but container replacement failed.\n' exit 1 fi)The migration file uses the schema-owning role in only mode. The existing
runtime file keeps the restricted application role and skip mode. If the
migration job succeeded but removal of the old container failed, inspect the
printed ID and finish removing that stopped container before recreating Roster.
If creation or startup failed, fix the reported problem. The function removes
a replacement whose start failed by its exact container ID. If that cleanup
fails, inspect the printed ID and remove that failed replacement before
retrying. In the same shell, run only create_roster_replacement to retry
container creation after a successful migration. Use the
readiness and functional checks
before returning traffic.
Changing database engines
Section titled “Changing database engines”Roster does not currently provide a supported SQLite-to-PostgreSQL or PostgreSQL-to-SQLite transfer command. Do not copy a SQLite file into a PostgreSQL deployment, point two deployments at different databases during a rolling update, or attempt to translate the physical schemas directly. The two engines expose the same Roster behavior but use different physical schemas and data types.
An existing customer upgrading from Roster 1.0.x should keep SQLite and the
same /data volume unless a separately planned data-migration project has been
validated for that customer. Back up the source deployment before any such
project and test record counts, authentication, provider configuration,
permissions, and representative Resolve history before cutover.
Backups
Section titled “Backups”Store backups off-host, encrypt them at rest, define a retention policy, and test restores regularly in an isolated deployment.
SQLite backup and restore
Section titled “SQLite backup and restore”The production image includes roster-sqlite, which uses SQLite’s online
backup API to create a consistent standalone database while Roster remains
running. Roster 1.0.x images do not include roster-sqlite. Use the
complete-state backup for those images
and for rollback that requires all of /data. Do not copy a live
roster.db, roster.db-wal, and roster.db-shm one at a time.
Create a backup inside a running Docker container:
roster_container=rosterroster_image="$(docker inspect --format '{{.Image}}' "$roster_container")"backup_dir="$(mktemp -d "$PWD/roster-db-backup.XXXXXX")"backup_name="roster-$(date -u +%Y-%m-%dT%H%M%SZ).db"( set -e umask 077 printf '%s\n' "$roster_image" > "$backup_dir/previous-image" docker image inspect --format '{{range .RepoDigests}}{{println .}}{{end}}' "$roster_image" \ > "$backup_dir/previous-image-digests")
docker exec "$roster_container" \ roster-sqlite backup \ --output "/data/.roster-backups/$backup_name"
docker cp \ "${roster_container}:/data/.roster-backups/$backup_name" \ "$backup_dir/$backup_name.partial"chmod 600 "$backup_dir/$backup_name.partial"Verify the copied file with the same Roster image, then publish it under its final name and remove the container copy. Run the next block in the same terminal so the container, image, backup directory, and file name match the backup step:
docker run --rm --user 0 \ --entrypoint roster-sqlite \ --mount "type=bind,src=$backup_dir,dst=/backups,readonly" \ "$roster_image" \ verify --input "/backups/$backup_name.partial" --full && mv "$backup_dir/$backup_name.partial" "$backup_dir/$backup_name" && docker exec "$roster_container" rm -f "/data/.roster-backups/$backup_name"backup refuses to overwrite an existing destination. It writes a private
temporary file, runs quick_check and foreign_key_check, synchronizes the
file, and atomically publishes it with mode 0600. Add --full to use
integrity_check, --json for machine-readable file-backup metadata, or
--stall-timeout-ms <milliseconds> to change the default 30-second no-progress
limit. The /data volume needs enough free space for a complete temporary
database in addition to normal database and WAL growth.
Hosted containers
Section titled “Hosted containers”When the container runs on a hosting platform, use a scheduled operations
runner and a binary-safe, non-TTY exec command. --stdout creates and verifies
a temporary online backup inside the container, emits only database bytes to
stdout, reports its SHA-256 checksum on stderr, and removes the temporary file
after streaming. The platform exec transport must preserve stdout and stderr
separately and must not truncate output. The following block is a transport
pattern, not a literal command: replace both angle-bracketed commands with the
non-interactive exec and object-storage commands for the hosting platform.
set -o pipefail
<platform-exec-no-tty> roster-sqlite backup --stdout | <object-store-upload-from-stdin> \ roster/production/roster-2026-07-13T020000Z.dbFor example, a Kubernetes operations runner can stream a single-instance StatefulSet backup to S3-compatible storage:
set -o pipefail
kubectl exec roster-0 -- roster-sqlite backup --stdout | aws s3 cp - \ s3://company-backups/roster/production/roster-2026-07-13T020000Z.dbKeep object-storage credentials in the operations runner rather than the
Roster container. Use platform-native atomic volume snapshots or a same-pod
backup sidecar when the database is too large for the platform exec control
plane. Download backups periodically, run
roster-sqlite verify --input <absolute-path> --full, and perform an isolated
restore drill.
The command exits with 0 on success, 1 for an operational failure, 2 for
invalid arguments or database configuration, and 3 when verification fails.
It rejects PostgreSQL and in-memory database configurations.
Complete Roster state and restore
Section titled “Complete Roster state and restore”An online database backup contains roster.db, but not connector files, worker
journals, or other runtime state stored under /data. Protect that additional
state with an atomic provider volume snapshot. If atomic snapshots are not
available, stop Roster before archiving the complete /data directory.
For Docker, run the following after stopping writes and before removing the
old container. This archives the full contents of its /data mount, including
CSV connector files. If SQLite uses a path outside /data, or you use
PostgreSQL, also take the database backup at the same recovery point.
roster_container=rosterbackup_dir="$(mktemp -d "$PWD/roster-state-backup.XXXXXX")"
( set -eu umask 077 docker stop "$roster_container" previous_image="$(docker inspect --format '{{.Image}}' "$roster_container")" printf '%s\n' "$previous_image" > "$backup_dir/previous-image" docker image inspect --format '{{range .RepoDigests}}{{println .}}{{end}}' "$previous_image" \ > "$backup_dir/previous-image-digests" docker cp -a "$roster_container:/data/." - > "$backup_dir/data.tar.partial" tar -tf "$backup_dir/data.tar.partial" >/dev/null mv "$backup_dir/data.tar.partial" "$backup_dir/data.tar")Retain the protected backup directory, the exact previous image, and the old
deployment settings. If the recorded image ID is unavailable locally, pull a
recorded registry digest from previous-image-digests on a host with the same
platform and confirm its image ID matches previous-image. If the image has no
registry digest, retain an image export for recovery on another host. The same
image recovery steps apply to a database-only backup.
To restore the archive, set backup_dir to that backup directory. The example
restores and compares the archive in a new named volume while the original
volume remains available. Keep both volumes until you accept the restored data.
( set -eu previous_image="$(cat "$backup_dir/previous-image")" docker image inspect --format '{{.Id}}' "$previous_image" >/dev/null restore_marker="$(mktemp -d "${TMPDIR:-/tmp}/roster-restore.XXXXXXXXXXXXXXXX")" trap 'rmdir "$restore_marker"' EXIT restore_token="${restore_marker##*.}" restored_volume="roster_data_restored_${restore_token:0:8}" existing_volumes="$(docker volume ls --format '{{.Name}}')" if printf '%s\n' "$existing_volumes" | grep -Fxq "$restored_volume"; then printf >&2 'Restore volume already exists: %s\n' "$restored_volume" exit 1 fi docker volume create --label "roster.restore=$restore_token" "$restored_volume" >/dev/null if [ "$(docker volume inspect --format '{{index .Labels "roster.restore"}}' "$restored_volume")" != "$restore_token" ]; then printf >&2 'Could not claim a new restore volume: %s\n' "$restored_volume" exit 1 fi docker run --rm -i --user 0 --entrypoint /bin/sh \ --mount "type=volume,src=$restored_volume,dst=/data,volume-nocopy" \ "$previous_image" -c 'set -eu test -z "$(ls -A /data)" tar --numeric-owner -xpf - -C /data' < "$backup_dir/data.tar" docker run --rm -i --user 0 --entrypoint tar \ --mount "type=volume,src=$restored_volume,dst=/data,readonly" \ "$previous_image" --numeric-owner -dpf - -C /data < "$backup_dir/data.tar" printf 'Restored volume: %s\n' "$restored_volume")For rollback, recreate Roster with the recorded previous image and settings
and mount the printed restored volume at /data. Restore any separately
backed-up database from the matching recovery point before starting Roster.
In an isolated deployment, confirm the previous version starts. Check
/health/ready if that version provides it, then sign in and verify
representative data and restored connector files before returning traffic.
Restore a database-only SQLite backup
Section titled “Restore a database-only SQLite backup”Use this option when your backup is a standalone SQLite database and you only need database data. For connector files and other runtime state, use the full archive above. Restore into a new volume without old SQLite WAL files.
Set roster_image to the exact image ID or digest from the backup,
backup_dir to the directory holding the backup, and backup_name to its
file name. For Docker, first verify the downloaded backup:
backup_dir="/path/to/private-backup-directory"roster_image="$(cat "$backup_dir/previous-image")"backup_name=roster-2026-07-16T020000Z.db
docker run --rm --user 0 \ --entrypoint roster-sqlite \ --mount "type=bind,src=$backup_dir,dst=/backups,readonly" \ "$roster_image" \ verify --input "/backups/$backup_name" --fullAfter verification succeeds, install the verified database in a new named volume with the runtime user’s ownership. The old volume remains available.
( set -eu roster_container=roster
restore_marker="$(mktemp -d "${TMPDIR:-/tmp}/roster-restore.XXXXXXXXXXXXXXXX")" trap 'rmdir "$restore_marker"' EXIT restore_token="${restore_marker##*.}" restored_volume="roster_data_restored_${restore_token:0:8}" existing_volumes="$(docker volume ls --format '{{.Name}}')" if printf '%s\n' "$existing_volumes" | grep -Fxq "$restored_volume"; then printf >&2 'Restore volume already exists: %s\n' "$restored_volume" exit 1 fi docker volume create --label "roster.restore=$restore_token" "$restored_volume" >/dev/null if [ "$(docker volume inspect --format '{{index .Labels "roster.restore"}}' "$restored_volume")" != "$restore_token" ]; then printf >&2 'Could not claim a new restore volume: %s\n' "$restored_volume" exit 1 fi docker stop "$roster_container"
docker run --rm --user 0 --entrypoint /bin/sh \ --env BACKUP_NAME="$backup_name" \ --mount "type=bind,src=$backup_dir,dst=/backups,readonly" \ --mount "type=volume,src=$restored_volume,dst=/data,volume-nocopy" \ "$roster_image" -c 'set -eu test -z "$(ls -A /data)" cp "/backups/$BACKUP_NAME" /data/roster.db chown node:node /data /data/roster.db chmod 600 /data/roster.db'
docker run --rm --entrypoint roster-sqlite \ --mount "type=volume,src=$restored_volume,dst=/data,readonly" \ "$roster_image" verify --input /data/roster.db --full printf 'Restored volume: %s\n' "$restored_volume")Create the replacement Roster container with the same image, secrets, ports,
network, and runtime settings. Omit ROSTER_SEED so evaluation seeding does
not run against the restored database. Mount the printed restored volume at
/data. Start exactly one instance. Confirm
startup migrations complete, then test the health probes, login, and a
representative read before returning traffic. Keep the stopped container and
old volume until the restore is accepted.
On a hosting platform, use the equivalent controlled workflow:
- Download the object-store backup and verify it with the exact Roster image that will perform the restore.
- Stop or scale the SQLite workload to zero and prevent automatic restarts.
- Provision a clean block volume with local filesystem semantics.
- Run a one-off restore job that mounts the backup read-only and the clean
volume at
/data, then installs the file as/data/roster.dbwith mode0600and ownership for the image’snodeuser. - Run
roster-sqlite verify --input /data/roster.db --fullfrom a one-off job with the restored volume mounted read-only. - Attach the restored volume to one Roster instance, enable automatic restarts, and complete the same migration, health, login, and read checks.
- Retain the previous volume and deployment configuration until the recovery point and application behavior are confirmed.
If recovery requires connector files or other non-database state, restore the
matching atomic /data snapshot instead of combining the database backup with
files from an unrelated recovery point.
Take a fresh, consistent backup of the database and complete /data state
before image upgrades or database migrations. Store every backup off-host, encrypt it at
rest, and enforce retention outside the Roster container.
PostgreSQL backups
Section titled “PostgreSQL backups”Back up PostgreSQL with the database provider’s backup process.
- Include the database and all Roster schemas in the provider backup policy.
- Enable point-in-time recovery when the provider supports it and monitor the last successful backup and recovery window.
- Keep
/databacked up when it contains connector files, worker journals, or other runtime state. - Take a fresh database backup before image upgrades, platform changes, or database migrations.
- Restore backups into an isolated PostgreSQL 17 or 18 environment on a regular schedule; never use the production database for a restore drill.
- Verify that the restricted runtime role can use a restored database after privileged migrations have completed.
- After a restore, start one Roster instance first and verify readiness, login, representative reads and writes, worker processing, and connector access before restoring normal replica counts and traffic.
Continue with High Availability or Hosting Platforms after selecting the database.