-
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.
- Loading branch information
1 parent
8af7e0a
commit ea97d00
Showing
7 changed files
with
137 additions
and
10 deletions.
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
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,22 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
export PATH="$PATH:$DP_DATASAFED_BIN_PATH" | ||
# 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 | ||
|
||
java -cp /zoocreeper.jar com.boundary.zoocreeper.Backup \ | ||
-z ${DP_DB_HOST}:${MY_ZOOKEEPER_ZOOKEEPER_SERVICE_PORT_CLIENT} --compress | \ | ||
datasafed push -z zstd-fastest - "${DP_BACKUP_NAME}.backup.json" | ||
|
||
TOTAL_SIZE=$(datasafed stat / | grep TotalSize | awk '{print $2}') | ||
echo "{\"totalSize\":\"$TOTAL_SIZE\"}" >"${DP_BACKUP_INFO_FILE}" |
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,19 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
|
||
export PATH="$PATH:$DP_DATASAFED_BIN_PATH" | ||
TMP_DIR=/tmp/zookeeper/restore | ||
mkdir -p ${TMP_DIR} | ||
|
||
backupFileName="${DP_BACKUP_NAME}.backup.json" | ||
datasafed pull -d zstd-fastest "${backupFileName}" ${TMP_DIR}/backup.json | ||
|
||
touch ${ZOOKEEPER_DATA_DIR}/.restore_new_cluster | ||
|
||
java -cp /zoocreeper.jar com.boundary.zoocreeper.Restore \ | ||
-z ${KB_CLUSTER_COMP_NAME}:${DP_DB_PORT} -f ${TMP_DIR}/backup.json \ | ||
--overwrite-existing --compress --exclude /zookeeper/config* | ||
|
||
rm -rf ${TMP_DIR} | ||
rm -rf ${ZOOKEEPER_DATA_DIR}/.restore_new_cluster |
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,36 @@ | ||
apiVersion: dataprotection.kubeblocks.io/v1alpha1 | ||
kind: ActionSet | ||
metadata: | ||
name: zookeeper-backup-zoocreeper | ||
labels: | ||
{{- include "zookeeper.labels" . | nindent 4 }} | ||
spec: | ||
backupType: Full | ||
env: | ||
- name: DATA_DIR | ||
value: "" | ||
- name: DATA_LOG_DIR | ||
value: "" | ||
backup: | ||
backupData: | ||
image: {{ .Values.images.registry | default "docker.io" }}/apecloud/zoocreeper:latest | ||
runOnTargetPodNode: true | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
{{- .Files.Get "dataprotection/backup.sh" | nindent 10 }} | ||
syncProgress: | ||
enabled: true | ||
intervalSeconds: 5 | ||
|
||
restore: | ||
postReady: | ||
- job: | ||
image: {{ .Values.images.registry | default "docker.io" }}/apecloud/zoocreeper:latest | ||
runOnTargetPodNode: true | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
{{- .Files.Get "dataprotection/restore.sh" | nindent 14 }} |
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,24 @@ | ||
apiVersion: apps.kubeblocks.io/v1alpha1 | ||
kind: BackupPolicyTemplate | ||
metadata: | ||
name: {{ include "zookeeper.fullname" . }}-backup-policy-template | ||
labels: | ||
{{- include "zookeeper.labels" . | nindent 4 }} | ||
service-kind/zookeeper: "true" | ||
annotations: | ||
dataprotection.kubeblocks.io/is-default-policy-template: "true" | ||
spec: | ||
backupPolicies: | ||
- componentDefs: [zookeeper] | ||
target: | ||
role: follower | ||
backupMethods: | ||
- name: zoocreeper | ||
snapshotVolumes: false | ||
actionSetName: zookeeper-backup-zoocreeper | ||
targetVolumes: | ||
volumeMounts: | ||
- name: data | ||
mountPath: /bitnami/zookeeper/data | ||
- name: snapshot-log | ||
mountPath: /bitnami/zookeeper/log |
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