Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions bin/with_tmpdir
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

if [ $# -lt 2 ]; then
echo "Usage: $0 <TMPDIR_PATTERN> <CMD> <ARGS...>" >&2
exit 1
fi

TMPDIR_PATTERN=$1
shift
export TMPDIR=$(mktemp -d "${TMPDIR_PATTERN}")

if [ -z "${TMPDIR}" ]; then
echo "Couldn't create temp directory, exiting" >&2
exit 1
fi


echo "Created temp directory ${TMPDIR}" >&2

cleanup() {
local rc=$?

if [ -z "${EXITCODE}" ]; then
kill %% >/dev/null
fi

if [ -e "${TMPDIR}" ]; then
echo "Removing temp directory ${TMPDIR} ..."
rm -rf -- "${TMPDIR}"
fi

# restore the original exit status
exit ${EXITCODE:-$rc}
}

trap cleanup EXIT

"$@" &
wait %%
EXITCODE=$?
2 changes: 1 addition & 1 deletion config/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ backend bk_db
option httpchk GET /flycheck/role
http-check expect string primary
http-check disable-on-404
server-template pg 10 $PRIMARY_REGION.$FLY_APP_NAME.internal:5433 check port 5500 resolvers flydns resolve-prefer ipv6 init-addr none on-marked-down shutdown-sessions
server-template pgprimaryregion 10 $PRIMARY_REGION.$FLY_APP_NAME.internal:5433 check port 5500 resolvers flydns resolve-prefer ipv6 init-addr none on-marked-down shutdown-sessions
server-template pg 10 $FLY_APP_NAME.internal:5433 check port 5500 resolvers flydns resolve-prefer ipv6 init-addr none on-marked-down shutdown-sessions
server pg [$PG_LISTEN_ADDRESS]:5433 check backup port 5500 on-marked-down shutdown-sessions
4 changes: 2 additions & 2 deletions internal/flypg/barman.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (b *Barman) Backup(ctx context.Context, cfg BackupConfig) ([]byte, error) {
args = append(args, "-n", cfg.Name)
}

return utils.RunCmd(ctx, "postgres", "barman-cloud-backup", args...)
return utils.RunCmd(ctx, "postgres", "with_tmpdir", append([]string{"/data/barman.tmp.XXXXXXXX", "barman-cloud-backup"}, args...)...)
}

// RestoreBackup returns the command string used to restore a base backup.
Expand All @@ -149,7 +149,7 @@ func (b *Barman) RestoreBackup(ctx context.Context, name string) ([]byte, error)
defaultRestoreDir,
}

return utils.RunCmd(ctx, "postgres", "barman-cloud-restore", args...)
return utils.RunCmd(ctx, "postgres", "with_tmpdir", append([]string{"/data/barman.tmp.XXXXXXXX", "barman-cloud-restore"}, args...)...)
}

func (b *Barman) ListBackups(ctx context.Context) (BackupList, error) {
Expand Down
2 changes: 1 addition & 1 deletion pg17/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ARG PG_MAJOR_VERSION
ARG PG_VERSION
ARG POSTGIS_MAJOR=3
ARG HAPROXY_VERSION=2.8
ARG REPMGR_VERSION=5.5.0+debpgdg-1.pgdg24.04+1
ARG REPMGR_VERSION=5.5.0+debpgdg-3.pgdg24.04+1

ENV PGDATA=/data/postgresql
ENV PGPASSFILE=/data/.pgpass
Expand Down