Skip to content

Backup and Restore

Production deployments must back up two categories of data:

DataRequiredReason
PostgreSQLRequiredUsers, rooms, permissions, provider instances, preferences, audit data, and business data live there
Production secretsRequiredJWT, OPAQUE, credential encryption, cluster, and management secrets affect login and decryption
Configuration filesStrongly recommendedRestore requires exact listeners, domains, dependencies, paths, and feature flags
Shared HLS storageAs neededRequired if you need to preserve HLS files or shared multi-replica segments
Proxy slice cacheUsually noIt is reproducible cache; losing it only lowers hit rate
RedisUsually not long-termRedis stores short-lived auth, rate-limit, and coordination state

Good for small and medium deployments:

Terminal window
pg_dump \
--format=custom \
--file=synctv-$(date +%Y%m%d-%H%M%S).dump \
"$DATABASE_URL"

Restore:

Terminal window
createdb synctv_restore
pg_restore \
--dbname=postgresql://synctv:password@localhost:5432/synctv_restore \
--clean \
--if-exists \
synctv-20260504-120000.dump

Store at least these values:

SettingRecommended storage
jwt.secretSecret Manager, Kubernetes Secret, password manager
security.opaque_server_setup_secretSecret Manager, offline encrypted backup
security.credential_encryption_keySecret Manager, offline encrypted backup
server.cluster_secretKubernetes Secret or Secret Manager
management.auth_tokenSecret Manager
metrics.auth.*Monitoring system secret
email.smtp_passwordSecret Manager
Provider token/API key/cookieSecret Manager or encrypted database storage

If you use _file settings, back up the file contents, not just the paths.

  1. Stop SyncTV to avoid writes during restore.
  2. Restore production secrets exactly as they were.
  3. Restore configuration files or deployment values.
  4. Restore PostgreSQL.
  5. Restore shared HLS storage if needed.
  6. Start the same SyncTV version and run synctv db status.
  7. If upgrading, follow Upgrades and Migrations for configuration, image, and rollback-risk checks.
  8. Start the service. Startup runs embedded SQLx migrations automatically, then check /health/ready, login, provider access, WebSocket, and metrics.

After restoring, run:

Terminal window
synctv db status
synctv config validate
curl -fsS http://localhost:8080/health/ready

Business checks:

  • Root/admin users can log in.
  • 2FA-enabled users can complete login.
  • Stored provider credentials decrypt and can reach upstream services.
  • Rooms, members, playlists, and permissions are present.
  • WebAuthn challenge and origin settings work if enabled.
  • OAuth2 redirect state reads and writes through Redis if enabled.

Recommended:

  • Run a restore drill before each major upgrade.
  • Run one after changing secret-management strategy.
  • Periodically confirm backups can be read, decrypted, and imported.

Do not stop at “backup job succeeded”. A useful backup restores into a SyncTV instance that can log in, play media, and be administered.

Redis loss does not usually destroy durable business data, but it changes short-term behavior:

  • OAuth2 state expires and users must restart OAuth2 login.
  • WebAuthn challenges expire and users must retry authentication.
  • Email codes expire and must be resent.
  • Token blacklist is lost, so revoked JWTs may remain valid until expiry.
  • Rate-limit counters reset.
  • Cluster nodes must register and catch up again.

If strong token revocation is required, use highly available Redis and keep token lifetimes short.