Import source: app/scripts/systemd-backup.sh

Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
This commit is contained in:
arsam
2026-09-18 23:23:48 +03:30
parent 7c039b1ee4
commit 8290360abd
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
BACKUP_DIR="${BACKUP_DIR:-/var/backups/teknav}"
RETENTION_DAYS="${BACKUP_RETENTION_DAYS:-14}"
STAMP="$(date -u +%Y%m%d-%H%M%S)"
OUT="${BACKUP_DIR}/teknav-${STAMP}.sql.gz"
mkdir -p "${BACKUP_DIR}"
chmod 750 "${BACKUP_DIR}"
pg_dump "${DATABASE_URL}" | gzip -9 > "${OUT}"
chmod 640 "${OUT}"
find "${BACKUP_DIR}" -type f -name 'teknav-*.sql.gz' -mtime "+${RETENTION_DAYS}" -delete
echo "[teknav-backup] wrote ${OUT}"