Skip to content

Commit 367a077

Browse files
Apurva Nisalcursoragent
andcommitted
ETCD-704: move extra etcd data dir files to backup subdirectory
Move leftover /var/lib/etcd entries to extra-data-dir-contents/ so staged snapshot.db, revision.json, and member/ are not overwritten. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4e87179 commit 367a077

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

bindata/etcd/cluster-restore.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,19 @@ function restore_static_pods() {
6262
}
6363

6464
function backup_remaining_etcd_data_dir_contents() {
65-
local entry base
65+
local entry base extras_dir="${ETCD_DATA_DIR_BACKUP}/extra-data-dir-contents"
66+
67+
mkdir -p "${extras_dir}"
6668

6769
shopt -s nullglob dotglob
6870
for entry in "${ETCD_DATA_DIR}"/*; do
6971
base=$(basename "${entry}")
70-
if [ -e "${ETCD_DATA_DIR_BACKUP}/${base}" ]; then
71-
echo "removing previous backup ${ETCD_DATA_DIR_BACKUP}/${base}"
72-
rm -rf "${ETCD_DATA_DIR_BACKUP:?}/${base}"
72+
if [ -e "${extras_dir}/${base}" ]; then
73+
echo "removing previous backup ${extras_dir}/${base}"
74+
rm -rf "${extras_dir:?}/${base}"
7375
fi
74-
echo "Moving ${entry} to ${ETCD_DATA_DIR_BACKUP}/"
75-
mv "${entry}" "${ETCD_DATA_DIR_BACKUP}/"
76+
echo "Moving ${entry} to ${extras_dir}/"
77+
mv "${entry}" "${extras_dir}/"
7678
done
7779
shopt -u nullglob dotglob
7880
}

0 commit comments

Comments
 (0)