sorintlab / stolon

PostgreSQL cloud native High Availability and more.
https://talk.stolon.io
Apache License 2.0
4.66k stars 447 forks source link

Can`t restore a backup #909

Open Vsevosemnog opened 1 year ago

Vsevosemnog commented 1 year ago

https://talk.stolon.io/t/can-t-restore-cluster-with-backup-pg-basebackup/255

Good day, need some help

Made a backup with the help of pg_basebackup

pg_basebackup --format=tar --verbose --write-recovery-conf --wal-method=stream 
 --gzip --compress=5 --host=$BACKUP_POSTGRES_HOST --port=$BACKUP_POSTGRES_PORT --username=$BACKUP_POSTGRES_USER \
 -D $outputfile

Could restore in in docker postgres but can`t restore in stolon clsuter in kubernetes

stolonctl version 0.17.0

The backup is located in /tmp/backup/, wal archive too

I tried different variants of stolonctl init, but they doesn`t work

stolonctl init '{ "initMode": "pitr", "pitrConfig": { "dataRestoreCommand": "tar -xzvf /tmp/backup/base.tar.gz -C %d" , "archiveRecoverySettings": { "restoreCommand": "cp /tmp/backup/pg_wal/%f %p" }, "recoveryTargetSettings": {"recoveryTarget": "immediate", "recoveryTargetAction":"promote"} } }' --cluster-name=stolon-dev --store-backend=kubernetes --kube-resource-kind=configmap

sentinel says

waiting for db to converge    {"db": "5d855218", "keeper": "keeper0"}

proxy says

no db object available, closing connections to master    {"db": ""}

keeper says

archive recovery complete
cp: cannot stat '/tmp/backup/pg_wal/00000001.history': No such file or directory
database system is ready to accept connections

after that postgres doesn`t respond what did i do wrong? image

Vsevosemnog commented 1 year ago

Found out that if i delete recovery.signal file everything is okay and restoration is done.

Why so? I even gave “recoveryTargetAction” parameter in init command