Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bindata/etcd/cluster-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ fi
dl_etcdctl
backup_latest_kube_static_resources "${BACKUP_RESOURCE_LIST[@]}"
ETCDCTL_ENDPOINTS="https://${NODE_NODE_ENVVAR_NAME_IP}:2379" etcdctl snapshot save "${SNAPSHOT_FILE}"

# Check the integrity of the snapshot
check_snapshot_status "${SNAPSHOT_FILE}"
echo "snapshot db and kube resources are successfully saved to ${BACKUP_DIR}"
4 changes: 4 additions & 0 deletions bindata/etcd/cluster-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ if [ ! -d "$MANIFEST_STOPPED_DIR" ]; then
mkdir -p "$MANIFEST_STOPPED_DIR"
fi

# Download etcdctl and check the snapshot status
dl_etcdctl
check_snapshot_status "${SNAPSHOT_FILE}"

# Move static pod manifests out of MANIFEST_DIR
for POD_FILE_NAME in "${STATIC_POD_LIST[@]}" etcd-pod.yaml; do
echo "...stopping ${POD_FILE_NAME}"
Expand Down
8 changes: 8 additions & 0 deletions bindata/etcd/etcd-common-tools
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ function exec_etcdctl {
fi
crictl exec -it $container_id /bin/sh -c "etcdctl $command"
}

function check_snapshot_status() {
local snap_file="$1"
if ! etcdctl snapshot status "${snap_file}" -w json; then
echo "Backup integrity verification failed. Backup appears corrupted. Aborting!"
return 1
fi
}
15 changes: 15 additions & 0 deletions pkg/operator/etcd_assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.