Update core-restore-from-backup.sh

This commit is contained in:
tteckster 2022-10-26 12:07:03 -04:00 committed by GitHub
parent 672b97dc52
commit aa18221a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 17 deletions

View File

@ -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
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