From 746d815169795844e4b9b18f471c576760798b12 Mon Sep 17 00:00:00 2001 From: shaojiang Date: Thu, 25 May 2023 11:44:41 +0800 Subject: [PATCH] chore: support PostgreSQL PITR if exists multi timeline (#3438) --- deploy/postgresql/templates/backuptool-pitr.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deploy/postgresql/templates/backuptool-pitr.yaml b/deploy/postgresql/templates/backuptool-pitr.yaml index 776787ca86f..e204db17a45 100644 --- a/deploy/postgresql/templates/backuptool-pitr.yaml +++ b/deploy/postgresql/templates/backuptool-pitr.yaml @@ -31,6 +31,7 @@ spec: - | set -e; rm -f ${CONF_DIR}/recovery.conf; + rm -rf ${PITR_DIR}; physical: restoreCommands: - | @@ -52,7 +53,10 @@ spec: echo "[[ -d '${DATA_DIR}.old' ]] && mv -f ${DATA_DIR}.old/* ${DATA_DIR}/;" >> ${RESTORE_SCRIPT_DIR}/kb_restore.sh; echo "sync;" >> ${RESTORE_SCRIPT_DIR}/kb_restore.sh; chmod +x ${RESTORE_SCRIPT_DIR}/kb_restore.sh; - echo "restore_command='mv ${PITR_DIR}/%f %p'\nrecovery_target_time='${RECOVERY_TIME}'\nrecovery_target_action='promote'" > ${CONF_DIR}/recovery.conf; + echo "restore_command='case "%f" in *history) cp ${PITR_DIR}/%f %p ;; *) mv ${PITR_DIR}/%f %p ;; esac'" > ${CONF_DIR}/recovery.conf; + echo "recovery_target_time='${RECOVERY_TIME}'" >> ${CONF_DIR}/recovery.conf; + echo "recovery_target_action='promote'" >> ${CONF_DIR}/recovery.conf; + echo "recovery_target_timeline='latest'" >> ${CONF_DIR}/recovery.conf; mv ${DATA_DIR} ${DATA_DIR}.old; echo "done."; sync;