mirror of https://github.com/tteck/Proxmox.git
Update core-restore-from-backup.sh
This commit is contained in:
parent
672b97dc52
commit
aa18221a45
|
@ -37,39 +37,33 @@ function msg_info() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
echo -ne " ${HOLD} ${YW}${msg}..."
|
||||||
}
|
}
|
||||||
|
|
||||||
function msg_ok() {
|
function msg_ok() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
DIR=/root/.homeassistant/restore
|
||||||
DIR=/root/.restore
|
|
||||||
if [ -d "$DIR" ];
|
if [ -d "$DIR" ];
|
||||||
then
|
then
|
||||||
msg_ok "Restore Directory Exists."
|
msg_ok "Restore Directory Exists."
|
||||||
else
|
else
|
||||||
mkdir -p /root/.restore
|
mkdir -p /root/.homeassistant/restore
|
||||||
msg_ok "Created Restore Directory."
|
msg_ok "Created Restore Directory."
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$(ls -A /root/.homeassistant/backups/)" ]; then echo -e "${RD}No backups found!${CL} \n"; exit 1; fi
|
||||||
cd /root/.homeassistant/backups/
|
cd /root/.homeassistant/backups/
|
||||||
PS3="Please enter your choice: "
|
PS3="Please enter your choice: "
|
||||||
files="$(ls -A .)"
|
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"
|
msg_info "Stopping Home Assistant"
|
||||||
sudo service homeassistant stop
|
sudo service homeassistant stop
|
||||||
msg_ok "Stopped Home Assistant"
|
msg_ok "Stopped Home Assistant"
|
||||||
|
|
||||||
msg_info "Restoring Home Assistant using ${filename}"
|
msg_info "Restoring Home Assistant using ${filename}"
|
||||||
tar xvf ${filename} -C /root/.restore &>/dev/null
|
tar xvf ${filename} -C /root/.homeassistant/restore &>/dev/null
|
||||||
cd /root/.restore
|
cd /root/.homeassistant/restore
|
||||||
tar -xvf homeassistant.tar.gz &>/dev/null
|
tar -xvf homeassistant.tar.gz &>/dev/null
|
||||||
if ! command -v rsync >/dev/null 2>&1; then
|
if ! command -v rsync >/dev/null 2>&1; then apt-get install -y rsync &>/dev/null; fi
|
||||||
apt-get install -y rsync &>/dev/null
|
rsync -a /root/.homeassistant/restore/data/ /root/.homeassistant
|
||||||
fi
|
rm -rf /root/.homeassistant/restore/*
|
||||||
rsync -a /root/.restore/data/ /root/.homeassistant
|
|
||||||
|
|
||||||
rm -rf /root/.restore/*
|
|
||||||
msg_ok "Restore Complete"
|
msg_ok "Restore Complete"
|
||||||
msg_ok "Starting Home Assistant"
|
msg_ok "Starting Home Assistant \n"
|
||||||
sudo service homeassistant start
|
sudo service homeassistant start
|
||||||
|
|
Loading…
Reference in New Issue