[tasks] Fix backup locations
All checks were successful
build & deploy / test (push) Successful in 1m57s
build & deploy / build-and-deploy (push) Successful in 30s

This commit is contained in:
2026-05-24 12:47:12 -04:00
parent 6927729284
commit 0639033aa9
3 changed files with 15 additions and 7 deletions

View File

@ -29,14 +29,15 @@ A backup command is available via `./manage.py backup_database` (also runs on a
Configure these additional settings as needed: Configure these additional settings as needed:
``` ```
DB_BACKUP_SSH_KEY="/path/to/ssh/private/key" VROBBLER_DB_BACKUP_SSH_KEY="/path/to/ssh/private/key"
DB_BACKUP_SSH_DEST="user@backup.example.com:/remote/path/" VROBBLER_DB_BACKUP_SSH_DEST="user@backup.example.com:/remote/path/"
DB_BACKUP_NTFY_URL="https://ntfy.sh/your-topic" VROBBLER_DB_BACKUP_NTFY_URL="https://ntfy.sh/your-topic"
``` ```
- `DB_BACKUP_SSH_KEY` — Path to the SSH private key used for remote copy. - `VROBBLER_DB_BACKUP_SSH_KEY` — Path to the SSH private key used for remote copy.
- `DB_BACKUP_SSH_DEST` — SCP destination (user@host:path). If set alongside SSH_KEY, the backup is copied to the remote host and old backups are pruned. - `VROBBLER_DB_BACKUP_SSH_DEST` — SCP destination (user@host:path). If set, the backup is copied to the remote host and old backups are pruned.
- `DB_BACKUP_NTFY_URL` — ntfy.sh URL for success notifications. Defaults to `https://ntfy.unbl.ink/backups`. - `VROBBLER_DB_BACKUP_LOCAL_DIR` — Local directory for backup storage. Defaults to `/var/backups/`. Backups are stored in a `vrobbler/` subdirectory.
- `VROBBLER_DB_BACKUP_NTFY_URL` — ntfy.sh URL for success notifications. Defaults to `https://ntfy.unbl.ink/backups`.
Retention is hardcoded: keeps daily backups for 7 days, plus one per month for 12 months. Retention is hardcoded: keeps daily backups for 7 days, plus one per month for 12 months.
``` ```

View File

@ -327,6 +327,7 @@ def _run_remote_cleanup(ssh_key, ssh_host, remote_path):
return return
from datetime import datetime from datetime import datetime
now = datetime.now() now = datetime.now()
to_delete = _retention_files_to_delete(files, now) to_delete = _retention_files_to_delete(files, now)
if not to_delete: if not to_delete:
@ -363,7 +364,7 @@ def backup_database():
logger.warning("backup_database skipped — not PostgreSQL") logger.warning("backup_database skipped — not PostgreSQL")
return return
backup_dir = Path("/var/backup/vrobbler") backup_dir = Path(settings.DB_BACKUP_LOCAL_DIR)
backup_dir.mkdir(parents=True, exist_ok=True) backup_dir.mkdir(parents=True, exist_ok=True)
date_str = datetime.now().strftime("%Y_%m_%d") date_str = datetime.now().strftime("%Y_%m_%d")
backup_path = backup_dir / f"vrobbler-backup-{date_str}.sql.gz" backup_path = backup_dir / f"vrobbler-backup-{date_str}.sql.gz"

View File

@ -66,6 +66,12 @@ IGDB_CLIENT_ID = os.getenv("VROBBLER_IGDB_CLIENT_ID")
IGDB_CLIENT_SECRET = os.getenv("VROBBLER_IGDB_CLIENT_SECRET") IGDB_CLIENT_SECRET = os.getenv("VROBBLER_IGDB_CLIENT_SECRET")
COMICVINE_API_KEY = os.getenv("VROBBLER_COMICVINE_API_KEY") COMICVINE_API_KEY = os.getenv("VROBBLER_COMICVINE_API_KEY")
BGG_ACCESS_TOKEN = os.getenv("VROBBLER_BGG_ACCESS_TOKEN", "") BGG_ACCESS_TOKEN = os.getenv("VROBBLER_BGG_ACCESS_TOKEN", "")
DB_BACKUP_SSH_KEY = os.getenv("VROBBLER_DB_BACKUP_SSH_KEY", "")
DB_BACKUP_SSH_DEST = os.getenv("VROBBLER_DB_BACKUP_SSH_DEST", "")
DB_BACKUP_LOCAL_DIR = os.getenv("VROBBLER_DB_BACKUP_LOCAL_DIR", "/var/backups/")
DB_BACKUP_NTFY_URL = os.getenv(
"VROBBLER_DB_BACKUP_NTFY_URL", "https://ntfy.unbl.ink/backups"
)
GEOLOC_ACCURACY = os.getenv("VROBBLER_GEOLOC_ACCURACY", 3) GEOLOC_ACCURACY = os.getenv("VROBBLER_GEOLOC_ACCURACY", 3)
GEOLOC_PROXIMITY = os.getenv("VROBBLER_GEOLOC_PROXIMITY", "0.0001") GEOLOC_PROXIMITY = os.getenv("VROBBLER_GEOLOC_PROXIMITY", "0.0001")
POINTS_FOR_MOVEMENT_HISTORY = os.getenv("VROBBLER_POINTS_FOR_MOVEMENT_HISTORY", 3) POINTS_FOR_MOVEMENT_HISTORY = os.getenv("VROBBLER_POINTS_FOR_MOVEMENT_HISTORY", 3)