Skip to content

Commit 7ed3661

Browse files
committed
fix: after restore from snapshot primary fail to restart
1 parent 6490aaf commit 7ed3661

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

stackgres-k8s/src/operator/src/main/resources/templates/create-backup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ do_backup() {
381381
-- psql -v ON_ERROR_STOP=1 -t -A > /tmp/backup-psql-out 2>&1 &
382382
echo $! > /tmp/backup-psql-pid
383383

384+
echo "Starting backup"
384385
cat << EOF >> /tmp/backup-psql
385386
SELECT 'Backup bootstrap';
386387
EOF
@@ -455,6 +456,7 @@ spec:
455456
source:
456457
persistentVolumeClaimName: $(cat /tmp/current-primary-pvc)
457458
EOF
459+
echo "Performing cleanup of backup restored files before creating the VolumeSnapshot"
458460
if ! retry kubectl exec -n "$CLUSTER_NAMESPACE" "$(cat /tmp/current-primary)" -c patroni -- \
459461
rm -rf "$PG_DATA_PATH.backup" "$PG_DATA_PATH/.restored_from_volume_snapshot" > /tmp/backup-cleanup 2>&1
460462
then
@@ -466,6 +468,7 @@ EOF
466468
kill "$(cat /tmp/backup-tail-pid)" || true
467469
exit 1
468470
fi
471+
echo "Creating VolumeSnapshot"
469472
cat /tmp/backup-cleanup
470473
if ! retry kubectl create -f /tmp/snapshot-to-create > /tmp/backup-snapshot 2>&1
471474
then
@@ -521,6 +524,7 @@ EOF
521524
sleep 1
522525
done
523526

527+
echo "Stopping backup"
524528
cat << EOF >> /tmp/backup-psql
525529
SET client_min_messages TO WARNING;
526530
SELECT

stackgres-k8s/src/operator/src/test/shell/backup/abstract-backup

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ EOF
154154
esac
155155
done
156156
;;
157+
("exec -n $CLUSTER_NAMESPACE $(cat /tmp/current-primary) -c patroni -- rm -rf "*)
158+
;;
157159
("create -f /tmp/snapshot-to-create")
158160
;;
159161
("get $VOLUME_SNAPSHOT_CRD_NAME -n $CLUSTER_NAMESPACE $BACKUP_NAME -o json")

0 commit comments

Comments
 (0)