-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: support to rebuild redis instance (#1417)
(cherry picked from commit 2b5ae1c)
- Loading branch information
Showing
5 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
|
||
# if the script exits with a non-zero exit code, touch a file to indicate that the backup failed, | ||
# the sync progress container will check this file and exit if it exists | ||
function handle_exit() { | ||
exit_code=$? | ||
if [ $exit_code -ne 0 ]; then | ||
echo "failed with exit code $exit_code" | ||
touch "${DP_BACKUP_INFO_FILE}.exit" | ||
exit 1 | ||
fi | ||
} | ||
trap handle_exit EXIT | ||
|
||
export PATH="$PATH:$DP_DATASAFED_BIN_PATH" | ||
export DATASAFED_BACKEND_BASE_PATH="$DP_BACKUP_BASE_PATH" | ||
cd ${DATA_DIR} | ||
if [ -f ./nodes.conf ]; then | ||
datasafed push ./nodes.conf "nodes.conf" | ||
fi | ||
datasafed push ./users.acl "users.acl" | ||
echo "INFO: save data file successfully" | ||
TOTAL_SIZE=$(datasafed stat / | grep TotalSize | awk '{print $2}') | ||
echo "{\"totalSize\":\"$TOTAL_SIZE\"}" >"${DP_BACKUP_INFO_FILE}" && sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
export PATH="$PATH:$DP_DATASAFED_BIN_PATH" | ||
export DATASAFED_BACKEND_BASE_PATH="$DP_BACKUP_BASE_PATH" | ||
mkdir -p ${DATA_DIR} | ||
res=`find ${DATA_DIR} -type f` | ||
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 placeholder file | ||
touch ${data_protection_file} | ||
cd ${DATA_DIR} | ||
datasafed pull "users.acl" "users.acl" | ||
if [ "${REBUILD_CLUSTER_INSTANCE}" == "true" ]; then | ||
touch rebuild.flag | ||
fi | ||
rm -rf ${data_protection_file} && sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters