SPB Git

Repository Public

BACKUP_RESTORE.md 3.7 KB

# Backup and restore

Status: scripts built; a restore drill runs in the automated tests (tests/studio-ops.test.ts). No backup has ever been taken of a real deployment — there is none.

# What must survive

What Where In a default backup
Database: editors and passkeys (public keys), working copy, every section body and figure, publications, audit log, jobs ATLAS_DATA_DIR/atlas.db yes — consistent snapshot (VACUUM INTO), taken while the site runs
Downloadable resources, all versions resources/ yes
Captions, transcripts, chapters media/**.vtt, media/**.json yes
Slide decks (SVG, thumbnails) slides/<session>/<deck>/ no — rebuild the packs from the course repository (pnpm slides:build) and import them again; the deck metadata and its publication are in the database
Original videos masters/<sha256>.<ext> no — listed in media-manifest.json; --with-masters, or rsync
Encoded renditions, posters media/** no — regenerable from masters; --with-media
Code and committed snapshot git by git
Learner progress each visitor's browser cannot be backed up by the server

# Commands (on the node, as the app's user)

bash
pnpm studio backup                     # → $ATLAS_DATA_DIR/backups/<UTC timestamp>/
pnpm studio backup --out /Volumes/X/atlas-2026-12-01 --with-masters --with-media
pnpm studio backup --keep 14           # retention: keep the 14 most recent in the backups directory
pnpm studio restore <backup-dir> --to <data-dir> [--force]
pnpm studio export <dir> [--with-resources]   # readable export of all content and metadata (also: Outils → Exporter)

A backup directory holds atlas.db, the copied files, media-manifest.json (every file under media/ and masters/ with its size, its SHA-256 when known, and whether it is in the backup) and backup.json (SHA-256 of every file in the backup, schema version, counts).

Before an upgrade: pnpm studio backup --out <somewhere off the data directory>, then deploy. Migrations are forward-only; going back means restoring that backup with the previous code.

# Restore

  1. Stop both processes (pm2 stop atlas-web atlas-worker): they hold the database open.
  2. pnpm studio restore <backup-dir> --to "$ATLAS_DATA_DIR". It verifies every checksum before touching anything; refuses a damaged backup or one from a newer application; refuses to replace an existing database unless --force, and then keeps the old one as atlas.db.remplacee-<timestamp>; replays migrations forward; runs PRAGMA integrity_check; prints the media files the backup does not contain.
  3. Bring back the listed masters/media (rsync from the other copy), or re-encode from masters (Traitements → Relancer, or re-attach the master).
  4. pm2 start atlas-web atlas-worker, then Outils → Liens et intégrité (or pnpm studio links) — it reports any file still missing for what is online.

# Retention and off-node copy — proposal, to be decided with the owner (nothing is scheduled)

  • Daily pnpm studio backup --keep 14 by a LaunchAgent/cron on the node; weekly copy of the newest backup and of masters/ to another machine (rsync -a --checksum). A backup that stays on the same disk protects against mistakes, not against the loss of the node.
  • Quarterly restore drill into a scratch directory (--to /tmp/atlas-restore), then ATLAS_DATA_DIR=/tmp/atlas-restore pnpm studio health.
  • The audit log is never pruned.

# Not built

Scheduling, off-node transfer, encryption of backups (they contain passkey public keys and the audit log with IP addresses — keep them on trusted disks), alerting when a backup is missing, point-in-time recovery.

Files main
Menu

Theme