openvibers/openvibe.host Commits
Data role: the pgBackRest step reads the stanza's status instead of guessing. A second run while the first full backup was still going took 'no valid backups' for 'no stanza' and tried stanza-create against the backup's lock. Now it creates the stanza only when pgBackRest says it is missing (status 1 or 3), starts a full backup only when none is valid and none is running (status 2), and warns on any other status.
Changes
@@@ -169,12 +169,20 @@ done# ── 8. The pgBackRest stanza and its schedule ───────────────────────────────────────────────if [ "$HAVE_REPO" = 1 ]; then-- if ! runuser -u postgres -- pgbackrest --stanza=openvibe info --output=json 2>/dev/null | grep -q '"status":{"code":0'; then++ # pgBackRest info status: 0 ok, 1 missing stanza path, 2 no valid backups, 3 missing stanza data (others: errors).++ code=$(runuser -u postgres -- pgbackrest --stanza=openvibe info --output=json 2>/dev/null \++ | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d[0]["status"]["code"] if d else 1)' 2>/dev/null || echo 1)++ if [ "$code" = 1 ] || [ "$code" = 3 ]; thenlog "creating the pgBackRest stanza"runuser -u postgres -- pgbackrest --stanza=openvibe stanza-createrunuser -u postgres -- pgbackrest --stanza=openvibe check-- log "starting the first full backup ([email protected])"++ code=2++ fi++ if [ "$code" = 2 ] && ! systemctl is-active -q [email protected]; then++ log "no valid backup yet: starting a full backup ([email protected])"systemctl start --no-block [email protected]++ elif [ "$code" != 0 ] && [ "$code" != 2 ]; then++ log "WARNING: pgBackRest reports status $code for stanza openvibe (run: sudo -u postgres pgbackrest --stanza=openvibe info)"fisystemctl enable -q --now pgbackrest-full.timer pgbackrest-diff.timerfi
@@ -169,12 +169,20 @@ done
@@ -169,12 +169,20 @@ done
# ── 8. The pgBackRest stanza and its schedule ───────────────────────────────────────────────
# ── 8. The pgBackRest stanza and its schedule ───────────────────────────────────────────────
if [ "$HAVE_REPO" = 1 ]; then
if [ "$HAVE_REPO" = 1 ]; then
- if ! runuser -u postgres -- pgbackrest --stanza=openvibe info --output=json 2>/dev/null | grep -q '"status":{"code":0'; then
+ # pgBackRest info status: 0 ok, 1 missing stanza path, 2 no valid backups, 3 missing stanza data (others: errors).
+ code=$(runuser -u postgres -- pgbackrest --stanza=openvibe info --output=json 2>/dev/null \
+ | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d[0]["status"]["code"] if d else 1)' 2>/dev/null || echo 1)
+ if [ "$code" = 1 ] || [ "$code" = 3 ]; then
log "creating the pgBackRest stanza"
log "creating the pgBackRest stanza"
runuser -u postgres -- pgbackrest --stanza=openvibe stanza-create
runuser -u postgres -- pgbackrest --stanza=openvibe stanza-create
runuser -u postgres -- pgbackrest --stanza=openvibe check
runuser -u postgres -- pgbackrest --stanza=openvibe check
- log "starting the first full backup ([email protected])"
+ code=2
+ fi
+ if [ "$code" = 2 ] && ! systemctl is-active -q [email protected]; then
+ log "no valid backup yet: starting a full backup ([email protected])"
systemctl start --no-block [email protected]
systemctl start --no-block [email protected]
+ elif [ "$code" != 0 ] && [ "$code" != 2 ]; then
+ log "WARNING: pgBackRest reports status $code for stanza openvibe (run: sudo -u postgres pgbackrest --stanza=openvibe info)"
fi
fi
systemctl enable -q --now pgbackrest-full.timer pgbackrest-diff.timer
systemctl enable -q --now pgbackrest-full.timer pgbackrest-diff.timer
fi
fi