Skip to content

Maintenance and Backups

Baytae Tistear edited this page Jul 7, 2026 · 2 revisions

Maintenance and Backups

Parent section: Operations

Maintenance covers backups, restore tests, storage cleanup, migrations, doctor checks, service health, and support bundles.

Dashboard Maintenance Areas

Relevant dashboard pages:

  • /admin/maintenance - backups, release status, restore tests, checksums, config restore, bot heartbeat, storage forecast, rollback queue, and health.
  • /admin/media - orphaned/missing media, oversized media, quarantine, thumbnails, compression, old-history archives, and lifecycle controls.
  • /admin/jobs - long-running maintenance jobs.
  • /admin/install-doctor - install/doctor status.
  • /admin/optimization - performance presets, cache metrics, storage forecasts, notification presets, queued maintenance, and watchdog status.
  • /admin/production-health - production health score.
  • /admin/server-health - per-server setup/storage/backup/game/library/achievement status.

Local Backups

Backups should protect:

  • sdac.db
  • config.json
  • media/
  • environment files
  • deployment scripts/configuration

Do not commit real backups to Git.

Restore Tests

Restore testing is important because a backup that has never been restored is only a guess.

Common command:

cd /home/ubuntu/discord-screenshot-bot
bash scripts/test_restore.sh

Specific backup:

bash scripts/test_restore.sh /home/ubuntu/discord-screenshot-bot/backups/sdac-BACKUP.db

Offsite Backups

Offsite backups can use rclone-backed providers such as Google Drive, OneDrive, Dropbox, Mega, S3, Backblaze B2, Box, and SFTP.

Example shape:

sudo apt install rclone
rclone config
SDAC_RCLONE_REMOTE=drive:sdac-backups bash scripts/backup_offsite.sh

Do not put rclone secrets, provider passwords, private keys, or token files in the wiki.

Per-Server Backups

Per-server backups export guild-scoped configuration, database rows, and media. The server-specific backup flow should not leak one server's private data into another server's export.

Local media cleanup after remote upload should stay disabled unless the remote media is reachable and tested.

Media Mirror

Media can optionally be mirrored to a cloud/public bucket. If a public prefix is used, set the environment variable name only in docs:

SDAC_MEDIA_PUBLIC_BASE_URL

Database Migrations

Run migrations after updates that change schema:

cd /home/ubuntu/discord-screenshot-bot
venv/bin/python scripts/migrate_database.py --db sdac.db

Archive Old History

Old full submission history can be archived while preserving monthly top 10 snapshots:

venv/bin/python scripts/archive_old_history.py --months 18

Remove exported rows from the live table only after verifying the archive:

venv/bin/python scripts/archive_old_history.py --months 18 --delete-exported

Doctor Checks

sdac-doctor checks install health. If it fails with /usr/bin/env: bash\r, the wrapper/script has CRLF line endings and must be converted to LF.

Doctor warnings about missing Discord token or OAuth credentials mean the server env file needs variable values; never paste those values into the wiki.

Clone this wiki locally