Make Naviya PostgreSQL backups atomic

This commit is contained in:
2026-08-08 20:53:45 +02:00
parent e4ae73ee28
commit 3f3b41040e
+13 -1
View File
@@ -46,7 +46,19 @@ spec:
- |
umask 077
stamp="$(date -u +%Y%m%dT%H%M%SZ)"
pg_dump --format=custom --no-owner --no-acl "$DATABASE_URL" > "/backups/application-metier-${stamp}.dump"
target="/backups/application-metier-${stamp}.dump"
tmp="${target}.tmp.$$"
cleanup() {
rm -f "$tmp"
}
trap cleanup EXIT
pg_dump --format=custom --no-owner --no-acl --file="$tmp" "$DATABASE_URL"
test -s "$tmp"
mv "$tmp" "$target"
trap - EXIT
ls -lh "$target"
find /backups -type f -name 'application-metier-*.dump' -mtime +14 -delete
env:
- name: DATABASE_URL