From aa18221a45f9b7bfc8e73318897ff889f15034d9 Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 26 Oct 2022 12:07:03 -0400 Subject: [PATCH] Update core-restore-from-backup.sh --- misc/core-restore-from-backup.sh | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/misc/core-restore-from-backup.sh b/misc/core-restore-from-backup.sh index fe5b1738..40b40425 100644 --- a/misc/core-restore-from-backup.sh +++ b/misc/core-restore-from-backup.sh @@ -37,39 +37,33 @@ function msg_info() { local msg="$1" echo -ne " ${HOLD} ${YW}${msg}..." } - function msg_ok() { local msg="$1" echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } - -DIR=/root/.restore +DIR=/root/.homeassistant/restore if [ -d "$DIR" ]; then msg_ok "Restore Directory Exists." else - mkdir -p /root/.restore - msg_ok "Created Restore Directory." + mkdir -p /root/.homeassistant/restore + msg_ok "Created Restore Directory." fi - +if [ -z "$(ls -A /root/.homeassistant/backups/)" ]; then echo -e "${RD}No backups found!${CL} \n"; exit 1; fi cd /root/.homeassistant/backups/ PS3="Please enter your choice: " files="$(ls -A .)" -select filename in ${files}; do msg_ok "You selected ${filename}"; break; done +select filename in ${files}; do msg_ok "You selected ${BL}${filename}${CL}"; break; done msg_info "Stopping Home Assistant" sudo service homeassistant stop msg_ok "Stopped Home Assistant" - msg_info "Restoring Home Assistant using ${filename}" -tar xvf ${filename} -C /root/.restore &>/dev/null -cd /root/.restore +tar xvf ${filename} -C /root/.homeassistant/restore &>/dev/null +cd /root/.homeassistant/restore tar -xvf homeassistant.tar.gz &>/dev/null -if ! command -v rsync >/dev/null 2>&1; then - apt-get install -y rsync &>/dev/null -fi -rsync -a /root/.restore/data/ /root/.homeassistant - -rm -rf /root/.restore/* +if ! command -v rsync >/dev/null 2>&1; then apt-get install -y rsync &>/dev/null; fi +rsync -a /root/.homeassistant/restore/data/ /root/.homeassistant +rm -rf /root/.homeassistant/restore/* msg_ok "Restore Complete" -msg_ok "Starting Home Assistant" +msg_ok "Starting Home Assistant \n" sudo service homeassistant start