Skip to content

Commit

Permalink
Fix backing up database to S3
Browse files Browse the repository at this point in the history
The script checks whether the dump file exists to avoid running pg_dump
twice. The check always passes because there is an empty file created by
mktemp therefore pg_dump is never run and the resulting dump is always
an empty file.

Fix the issue by creating an temporary directory where the dump file
will be created by pg_dump so the "dump file exists" check works as
intended.
  • Loading branch information
rce committed Sep 12, 2024
1 parent dd7565a commit 959f150
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backup/backup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail

readonly dump_file="$(mktemp)"
readonly dump_dir="$(mktemp --directory)"
readonly dump_file="${dump_dir}/dump"

function cleanup {
echo "Deleting dump file $dump_file"
Expand Down

0 comments on commit 959f150

Please sign in to comment.