Skip to content

Commit

Permalink
Merge pull request openshift#1346 from retroflexer/cleanup-and-commen…
Browse files Browse the repository at this point in the history
…t-backup-restore

DR: Cleanup and comment backup and restore scripts
  • Loading branch information
openshift-merge-robot authored Jan 2, 2020
2 parents 347a7a0 + c14ec0f commit 04cd219
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ contents:
backup_manifest
backup_latest_kube_static_resources
snapshot_data_dir
tar rf ${BACKUP_TAR_FILE} -C ${ASSET_DIR}/tmp snapshot.db
gzip ${BACKUP_TAR_FILE}
append_snapshot_to_tar_and_gzip
rm -f ${SNAPSHOT_FILE}
echo "snapshot db and kube resources are successfully saved to ${BACKUP_TAR_FILE}.gz!"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contents:
function run {
ETCD_INITIAL_CLUSTER="${INITIAL_CLUSTER}"
init
if [ ${BACKUP_FILE#*.} = "tar.gz" ]; then
if [[ ${BACKUP_FILE} =~ \.tar\.gz$ ]]; then
RESTORE_STATIC_RESOURCES="true"
tar xzf ${BACKUP_FILE} -C ${ASSET_DIR}/tmp/ snapshot.db
SNAPSHOT_FILE="${ASSET_DIR}/tmp/snapshot.db"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ contents:
if [ -f "$ASSET_DIR/backup/etcd-ca-bundle.crt" ] && [ -f "$ASSET_DIR/backup/etcd-client.crt" ] && [ -f "$ASSET_DIR/backup/etcd-client.key" ]; then
echo "etcd client certs already backed up and available $ASSET_DIR/backup/"
else
STATIC_DIRS=($(ls -td "${CONFIG_FILE_DIR}"/static-pod-resources/kube-apiserver-pod-[0-9]*))
if [ "$?" -ne 0 ]; then
STATIC_DIRS=($(ls -td "${CONFIG_FILE_DIR}"/static-pod-resources/kube-apiserver-pod-[0-9]*)) || true
if [ -z "${STATIC_DIRS}" ]; then
echo "error finding static-pod-resources"
exit 1
fi
Expand Down Expand Up @@ -69,9 +69,17 @@ contents:
echo "error finding static-pod-resources"
exit 1
fi
# tar up the static kube resources, with the path relative to CONFIG_FILE_DIR
tar -cpf $BACKUP_TAR_FILE -C ${CONFIG_FILE_DIR} ${LATEST_STATIC_POD_DIR#$CONFIG_FILE_DIR/}
}
append_snapshot_to_tar_and_gzip() {
# "r" flag is used to append snapshot.db to the existing tar archive
tar rf ${BACKUP_TAR_FILE} -C ${ASSET_DIR}/tmp snapshot.db
gzip ${BACKUP_TAR_FILE}
}
# backup current etcd-member pod manifest
backup_manifest() {
if [ -e "${ASSET_DIR}/backup/etcd-member.yaml" ]; then
Expand Down

0 comments on commit 04cd219

Please sign in to comment.