Skip to main content
Version: Development

Backup and recovery

A database dump alone cannot restore Melodee. All media, artwork, protected objects, volume markers, Catalog and identity state must form a consistent recovery point. This starter supplies database-only backup tooling, not an end-to-end backup system or automated destructive restore.

python3 scripts/system.py db-backup

The command uses the pinned PostgreSQL container's pg_dump -Fc, writes a private file in backups/, calculates a SHA-256 checksum and removes a failed dump. It does not stop workers or snapshot any other data. For a coherent recovery point, arrange a maintenance window, stop API/CLI writers and any external writers, retain PostgreSQL, and coordinate a database dump plus snapshots/copies of all registered media and protected-object stores. Verify mount identities.

Full backup inventory​

  • PostgreSQL logical dump (and/or qualified physical backup/PITR strategy).
  • api-data and all registered Storage Volumes with content, markers and owner epochs.
  • Exact distribution revision and versions.lock.json, private .env, optional provider settings, TLS/trust configuration and any reviewed Compose extensions.
  • Credentials/keys required to recover encrypted backups, separately protected.

Encrypt backups, restrict access, keep an off-host copy, define retention, record checksums and conduct restore rehearsals. Never send a DB dump or media snapshot to public issue trackers. A checksum proves integrity of a file, not restoreability.

Recovery procedure to qualify​

  1. Select a consistent backup and exact compatible prior distribution and pins.
  2. Restore into an isolated installation with different project name, hostname, database and media paths. Do not overwrite live volumes. Disable outbound notifications/provider actions until the restore is validated.
  3. Restore the database using the same supported PostgreSQL tooling into an empty destination; restore media/protected objects and volume marker identity at the expected paths. Confirm ownership and no source/destination overlap.
  4. Run schema compatibility check, start services and verify readiness, account recovery/sign-in, Track search, playlists/favorites, protected objects and ranged playback. Compare database invariants and media hashes.
  5. Only after a successful rehearsal plan a deliberate production cutover, DNS, client reconfiguration and rollback. Never blindly use pg_restore --clean against a running production system.

Real-size backup/restore, NAS snapshot tooling, PITR and operational recovery objectives are open qualification work. A production restore helper is deliberately not supplied until the recovery contracts and safeguards have been verified.