Skip to content

Commit f06ed90

Browse files
authored
Merge pull request #96 from cybertec-postgresql/Improvements
Improvements
2 parents 8261d2e + 2937c35 commit f06ed90

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

runit/patroni/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fi
2121
ulimit -c unlimited
2222

2323
# Only small subset of environment variables is allowed. We don't want accidentally disclose sensitive information
24-
for E in $(printenv -0 | tr '\n' ' ' | sed 's/\x00/\n/g' | grep -vE '^(KUBERNETES_(SERVICE|PORT|ROLE)[_=]|((POD_(IP|NAMESPACE))|HOSTNAME|PATH|PGHOME|LC_ALL|ENABLE_PG_MON|LD_PRELOAD|NSS_WRAPPER_PASSWD|NSS_WRAPPER_GROUP)=)' | sed 's/=.*//g'); do
24+
for E in $(printenv -0 | tr '\n' ' ' | sed 's/\x00/\n/g' | grep -vE '^(KUBERNETES_(SERVICE|PORT|ROLE)[_=]|((POD_(IP|NAMESPACE))|HOSTNAME|PATH|RW_DIR|PGHOME|LC_ALL|ENABLE_PG_MON|LD_PRELOAD|NSS_WRAPPER_PASSWD|NSS_WRAPPER_GROUP)=)' | sed 's/=.*//g'); do
2525
unset $E
2626
done
2727

scripts/postgres/stanza_upgrade.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,23 @@ if [ "$pg_version" != "$stanza_version" ]; then
2828
echo "INFO: stanza version matches another PostgreSQL version: A stanza upgrade is required to ensure that pgBackRest can work with the current version of PostgreSQL"
2929
if pgbackrest stanza-upgrade --stanza=db; then
3030
echo "INFO: stanza has been successfully updated. New Version: $pg_version. Creating a new backup ... "
31-
if pgbackrest backup --stanza=db --type=full --repo=1; then
32-
echo "INFO: Backup created successfully."
31+
pgbackrest backup --stanza=db --type=full --repo=1 > /dev/null 2>&1 &
32+
BACKUP_PID=$!
33+
sleep 5s
34+
if kill -0 $BACKUP_PID 2>/dev/null; then
35+
echo "INFO: Backup started successfully."
36+
disown $BACKUP_PID
3337
exit 0
3438
else
35-
echo "ERROR: Backup failed!"
36-
exit 1
39+
wait $BACKUP_PID
40+
EXIT_CODE=$?
41+
if [ $EXIT_CODE -eq 0 ]; then
42+
exit 0
43+
else
44+
echo "ERROR: Backup could not be started successfully!"
45+
tail -n 10 "$PGHOME/pgdata/pgbackrest/log/db-backup.log"
46+
exit 1
47+
fi
3748
fi
3849
else
3950
echo "ERROR: stanza upgrade failed!"

0 commit comments

Comments
 (0)