fix: finalize weekly postgres backup retention
All checks were successful
CI / test (pull_request) Successful in 9m11s
CI / deploy (pull_request) Has been skipped

This commit is contained in:
2026-09-15 18:50:22 +03:00
parent 384cd550d5
commit b933f95302
6 changed files with 10 additions and 8 deletions

View File

@@ -2,8 +2,8 @@
set -eu
umask 077
app_dir=/srv/miem_workers
backup_dir=/home/codex/backups/postgres
app_dir=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
backup_dir="$HOME/backups/postgres"
backup="$backup_dir/postgres-latest.sql"
temporary="$backup.tmp.$$"
@@ -14,5 +14,5 @@ cd "$app_dir"
docker compose exec -T postgres sh -c 'pg_dumpall -U "$POSTGRES_USER"' > "$temporary"
test -s "$temporary"
mv "$temporary" "$backup"
find /home/codex/backups/miem_workers -maxdepth 1 -type f -name 'miem_workers-*.sql' -delete 2>/dev/null || true
find "$HOME/backups/miem_workers" -maxdepth 1 -type f -name 'miem_workers-*.sql' -delete 2>/dev/null || true
printf '%s\n' "Created $backup"