Skip to content

Backup and restore

Data Rebuildable?
Watch definitions Yes — from YAML files, if you keep them
Run state (seen content, notified events, ledger, pending deliveries) No
Run history No
Trust rules Only by hand
Stored API keys Only by re-adding them
Accounts Only by recreating them

Most free database tiers provide no automated backups. If that is your setup, backups are your responsibility. The repository includes a scheduled workflow that takes a weekly compressed dump and retains it as a build artifact — a reasonable baseline for a personal instance.

Any standard MongoDB dump works:

Terminal window
mongodump --uri="$MongoDB_URI" --archive=watcher-backup.gz --gzip
  1. Stop anything that writes — pause the scheduled job and stop the service. Restoring underneath a running scheduler produces a mess.

  2. Restore the archive:

    Terminal window
    mongorestore --uri="$MongoDB_URI" --archive=watcher-backup.gz --gzip
  3. Check the encryption key. Stored API keys are encrypted with CONFIG_ENCRYPTION_KEY. Restoring the data to an environment with a different key means those keys cannot be decrypted — they will be skipped with a warning and Watcher falls back to environment keys.

  4. Sanity-check before resuming: pnpm watches:list shows your watches, and pnpm watches history <id> shows history from before the backup.

  5. Resume the scheduler.

If your backup predates alerts you already received, the restored state does not know about them and they may be re-sent. Options:

  • Accept one noisy run — usually simplest for a personal instance.
  • Disable the affected watches, let one run pass to re-learn current content, then re-enable. You will miss anything that changes in that window.
Keep Where
Watch definitions as YAML Version control
Environment configuration (names, not values) Documented alongside
Secrets Your platform’s secret store, or a password manager
A recent database dump Off the database host

With those four, a total loss is a rebuild of an hour, not a rewrite.

Per-process key cooldowns and rate-limiter windows are in memory and are simply lost. They self-heal; there is nothing to restore.