Make Naviya PostgreSQL backups atomic
This commit is contained in:
@@ -46,7 +46,19 @@ spec:
|
|||||||
- |
|
- |
|
||||||
umask 077
|
umask 077
|
||||||
stamp="$(date -u +%Y%m%dT%H%M%SZ)"
|
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
|
find /backups -type f -name 'application-metier-*.dump' -mtime +14 -delete
|
||||||
env:
|
env:
|
||||||
- name: DATABASE_URL
|
- name: DATABASE_URL
|
||||||
|
|||||||
Reference in New Issue
Block a user