mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-09-21 13:31:42 +00:00
Fix backup.sh: always clean up temp dump/tar files via EXIT trap
Previously the dump/tar cleanup only ran after restic forget succeeded, so a plaintext Postgres dump could be left behind in /tmp if tar or restic failed partway through. Add an EXIT trap that unconditionally removes both temp files on any exit path, and drop the now-redundant explicit rm -f from the success path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -11,6 +11,8 @@ trap report_failure ERR
|
|||||||
DUMP_FILE=/tmp/dragonsstash.dump
|
DUMP_FILE=/tmp/dragonsstash.dump
|
||||||
TAR_FILE=/tmp/tdlib.tar.gz
|
TAR_FILE=/tmp/tdlib.tar.gz
|
||||||
|
|
||||||
|
trap 'rm -f "$DUMP_FILE" "$TAR_FILE"' EXIT
|
||||||
|
|
||||||
pg_dump -h dragonsstash-db -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc -f "$DUMP_FILE"
|
pg_dump -h dragonsstash-db -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc -f "$DUMP_FILE"
|
||||||
|
|
||||||
tar czf "$TAR_FILE" -C /data tdlib-worker tdlib-bot
|
tar czf "$TAR_FILE" -C /data tdlib-worker tdlib-bot
|
||||||
@@ -18,8 +20,6 @@ tar czf "$TAR_FILE" -C /data tdlib-worker tdlib-bot
|
|||||||
restic backup "$DUMP_FILE" "$TAR_FILE"
|
restic backup "$DUMP_FILE" "$TAR_FILE"
|
||||||
restic forget --keep-daily 14 --prune
|
restic forget --keep-daily 14 --prune
|
||||||
|
|
||||||
rm -f "$DUMP_FILE" "$TAR_FILE"
|
|
||||||
|
|
||||||
curl -fsS "$KUMA_PUSH_URL" --get \
|
curl -fsS "$KUMA_PUSH_URL" --get \
|
||||||
--data-urlencode "status=up" \
|
--data-urlencode "status=up" \
|
||||||
--data-urlencode "msg=OK"
|
--data-urlencode "msg=OK"
|
||||||
|
|||||||
Reference in New Issue
Block a user