Skip to content

Commit

Permalink
fix: redis may restore fail (#4770)
Browse files Browse the repository at this point in the history
(cherry picked from commit 74271e5)
  • Loading branch information
wangyelei committed Aug 16, 2023
1 parent 9651498 commit 4b8db0f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion deploy/apecloud-mysql/templates/backuptool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ spec:
set -e;
mkdir -p ${DATA_DIR}
res=`ls -A ${DATA_DIR}`
if [ ! -z ${res} ]; then
data_protection_file=${DATA_DIR}/.kb-data-protection
if [ ! -z "${res}" ] && [ ! -f ${data_protection_file} ]; then
echo "${DATA_DIR} is not empty! Please make sure that the directory is empty before restoring the backup."
exit 1
fi
touch ${data_protection_file} && sync
TMP_DIR=/data/mysql/temp
mkdir -p ${TMP_DIR} && cd ${TMP_DIR}
xbstream -x < ${BACKUP_DIR}/${BACKUP_NAME}.xbstream
Expand All @@ -31,6 +33,7 @@ spec:
xtrabackup --move-back --target-dir=${TMP_DIR} --datadir=${DATA_DIR}/
touch ${DATA_DIR}/.xtrabackup_restore_new_cluster
rm -rf ${TMP_DIR}
rm -rf ${data_protection_file} && sync
chmod -R 0777 ${DATA_DIR}
incrementalRestoreCommands: []
logical:
Expand Down
5 changes: 4 additions & 1 deletion deploy/apecloud-mysql/templates/backuptoolforhscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ spec:
set -e;
mkdir -p ${DATA_DIR}
res=`ls -A ${DATA_DIR}`
if [ ! -z ${res} ]; then
data_protection_file=${DATA_DIR}/.kb-data-protection
if [ ! -z "${res}" ] && [ ! -f ${data_protection_file} ]; then
echo "${DATA_DIR} is not empty! Please make sure that the directory is empty before restoring the backup."
exit 1
fi
touch ${data_protection_file} && sync
mkdir -p /tmp/data/ && cd /tmp/data
xbstream -x < ${BACKUP_DIR}/${BACKUP_NAME}.xbstream
xtrabackup --decompress --target-dir=/tmp/data/
Expand All @@ -31,6 +33,7 @@ spec:
xtrabackup --move-back --target-dir=/tmp/data/ --datadir=${DATA_DIR}/
touch ${DATA_DIR}/.xtrabackup_restore
rm -rf /tmp/data/
rm -rf ${data_protection_file} && sync
chmod -R 0777 ${DATA_DIR}
incrementalRestoreCommands: []
logical:
Expand Down
5 changes: 4 additions & 1 deletion deploy/mongodb/templates/backuptool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ spec:
set -e
mkdir -p ${DATA_DIR}
res=`ls -A ${DATA_DIR}`
if [ ! -z "${res}" ]; then
data_protection_file=${DATA_DIR}/.kb-data-protection
if [ ! -z "${res}" ] && [ ! -f ${data_protection_file} ]; then
echo "${DATA_DIR} is not empty! Please make sure that the directory is empty before restoring the backup."
exit 1
fi
touch ${data_protection_file} && sync
tar -xvf ${BACKUP_DIR}/${BACKUP_NAME}.tar.gz -C ${DATA_DIR}
rm -rf ${data_protection_file} && sync
incrementalRestoreCommands: []
logical:
restoreCommands: []
Expand Down
5 changes: 4 additions & 1 deletion deploy/redis/templates/backuptool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ spec:
set -e
mkdir -p ${DATA_DIR}
res=`ls -A ${DATA_DIR}`
if [ ! -z "${res}" ]; then
data_protection_file=${DATA_DIR}/.kb-data-protection
if [ ! -z "${res}" ] && [ ! -f ${data_protection_file} ]; then
echo "${DATA_DIR} is not empty! Please make sure that the directory is empty before restoring the backup."
exit 1
fi
touch ${data_protection_file} && sync
tar -xvf ${BACKUP_DIR}/${BACKUP_NAME}.tar.gz -C ${DATA_DIR}
rm -rf ${data_protection_file} && sync
logical:
restoreCommands: []
backupCommands:
Expand Down

0 comments on commit 4b8db0f

Please sign in to comment.