Skip to content

Commit

Permalink
Merge pull request #35784 from wojtek-t/tweak_restore_script
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Support events in restore script

Ref #20504
  • Loading branch information
Kubernetes Submit Queue committed Nov 2, 2016
2 parents ddca9af + 7fe1e06 commit 94a6538
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cluster/restore-from-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
# - in case of etcd2 - *.snap and *.wal files are in current directory
# - in case of etcd3 - *.db file is in the current directory
# - the script is run as root
#
# The script doesn't support restoring event etcd.

# - for event etcd, we only support clearing it - to do it, you need to
# set RESET_EVENT_ETCD=true env var.

set -o errexit
set -o nounset
Expand All @@ -45,6 +44,12 @@ set -o pipefail
# the current one and create a file with such configuration.
# The restore procedure is chosen based on this information.
VERSION_FILE="version.txt"

# Make it possible to overwrite version file (or default version)
# with VERSION_CONTENTS env var.
if [ -n "${VERSION_CONTENTS:-}" ]; then
echo "${VERSION_CONTENTS}" > "${VERSION_FILE}"
fi
if [ ! -f "${VERSION_FILE}" ]; then
echo "2.2.1/etcd2" > "${VERSION_FILE}"
fi
Expand Down Expand Up @@ -205,6 +210,14 @@ mv /var/etcd/data "${MNT_DISK}/var/etcd-corrupted"
# Replace the corrupted data dir with the resotred data.
mv "${BACKUP_DIR}" /var/etcd/data

if [ "${RESET_EVENT_ETCD:-}" == "true" ]; then
EVENTS_CORRUPTED_DIR="${MNT_DISK}/var/etcd-events-corrupted"
# Save the corrupted data (clean directory if it is already non-empty).
rm -rf "${EVENTS_CORRUPTED_DIR}"
mkdir -p "${EVENTS_CORRUPTED_DIR}"
mv /var/etcd/data-events "${EVENTS_CORRUPTED_DIR}"
fi

# Start etcd and kube-apiserver again.
echo "Restarting etcd and apiserver from restored snapshot"
mv "${MANIFEST_BACKUP_DIR}"/* "${MANIFEST_DIR}/"
Expand Down

0 comments on commit 94a6538

Please sign in to comment.