maand snapshot

Catalog database snapshots for workers labeled maand.

Related: deploy.md · configuration.md

maand snapshot backup

Creates a consistent copy of data/maand.db (SQLite online backup) and rsyncs it to every worker with the maand label:

/opt/maand/<bucket_id>/backups/maand-<update_seq>.db

Example filename: maand-42.db. Re-running backup at the same update_seq overwrites that file.

Then keeps only the N highest update_seq backups on those workers according to backup_retention_count in maand.conf (default 7; 0 keeps forever). Legacy timestamp-named maand-*.db files are removed when pruning is enabled.

Requirements

Behavior

Aspect Detail
Targets data.GetWorkers(..., ["maand"])
Local snapshot Under tmp/, then transferred
Failure Non-zero exit (unlike deploy’s best-effort post-commit backup)
No targets Exits 0 and logs that nothing was targeted

Deploy also runs this path after commit + VACUUM (best-effort). Use the CLI when you want a backup without a full deploy (uses the current catalog update_seq; does not bump it).

Restore material in the catalog: each maand build copies onto the singleton bucket row:

Disk Column
maand.conf maand_conf
secrets/kv.key kv_key
secrets/ca.key ca_key
secrets/ca.crt ca_crt
workspace/workers.json workers_json
workspace/bucket.conf bucket_conf
workspace/disabled.json disabled_json
workspace/bucket.jobs*.conf bucket_jobs_confs (JSON map)
.ssh/known_hosts known_hosts

Job trees live in job_files (already in the catalog). Catalog backups on maand-labeled workers therefore contain CA/KV secrets, workspace sources, and SSH host pins — treat those hosts like the CLI host.

maand snapshot list

Lists remote catalog backups on every worker labeled maand:

Column Meaning
Worker Worker IP
Update Seq Parsed from maand-<update_seq>.db
Name Backup filename
Path Full path under /opt/maand/<bucket_id>/backups/

Sorted highest update_seq first. Rows are per worker (same filename on two hosts appears twice). With no maand workers, exits 0 and prints an empty table (and a short log line).

maand snapshot restore

# Copy a backup off a worker, then restore offline:
#   scp agent@worker:/opt/maand/<bucket_id>/backups/maand-42.db .
maand snapshot restore ./maand-42.db
maand snapshot restore ./maand-42.db --output /path/to/new-bucket

Reads a local catalog DB file (no SSH, no existing local bucket required) and writes a complete bucket tree under --output (default .):

  1. Copies the file to data/maand.db
  2. Writes maand.conf, secrets/kv.key, secrets/ca.key, secrets/ca.crt
  3. Writes secrets/ca-trust.crt from KV maand/worker / certs/ca-trust.crt (falls back to ca.crt if missing)
  4. Writes .ssh/known_hosts from the bucket row (empty file if none was stored)
  5. Recreates workspace/ from bucket columns (workers.json, bucket.conf, disabled.json, bucket.jobs*.conf) and exports job_files verbatim into workspace/jobs/
  6. Scaffolds templates/, logs/, tmp/, and .gitignore

Fails if output/data/maand.db already exists. Does not restore secrets/<ssh_key> — copy the SSH private key before deploy.