File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,15 @@ case "${PG_BACKUP_ACTION:-dump}" in
5858 export AWS_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY
5959 export AWS_DEFAULT_REGION=$S3_REGION
6060
61+ # Define a cleanup function
62+ cleanup () {
63+ echo " Cleaning up..."
64+ rm -f dump.backup
65+ }
66+
67+ # Set a trap to call the cleanup function when the script exits
68+ trap cleanup EXIT
69+
6170 # TODO: check if database is fresh
6271 echo " Snapshotting $POSTGRES_DB database"
6372 pg_dump -Fc $POSTGRES_HOST_OPTS $POSTGRES_DB > dump.backup
@@ -77,7 +86,6 @@ case "${PG_BACKUP_ACTION:-dump}" in
7786 fi
7887
7988 echo " Snapshot uploaded successfully, removing local file"
80- rm dump.backup
8189
8290 if [ ! -z " $HEARTBEAT_URI " ]; then
8391 echo " Sending heartbeat signal"
You can’t perform that action at this time.
0 commit comments