Skip to content

Commit 2937c35

Browse files
committed
backup is now running in the background - no need to wait for it
1 parent 05913eb commit 2937c35

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

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)