mirror of
https://github.com/tteck/Proxmox.git
synced 2024-12-25 06:21:56 +00:00
Update zwave-copy-data.sh
This commit is contained in:
parent
14aaaa47e4
commit
52364ed5d0
@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Use to copy all data from one Zwavejs2MQTT LXC to another
|
# Use to copy all data from a Zwavejs2MQTT LXC to a Z-wave JS UI LXC
|
||||||
# run from the Proxmox Shell
|
# run from the Proxmox Shell
|
||||||
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/zwave-copy-data.sh)"
|
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/zwave-copy-data.sh)"
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Use to copy all data from one Zwavejs2MQTT LXC to another. Proceed(y/n)?" yn
|
read -p "Use to copy all data from a Zwavejs2MQTT LXC to a Z-wave JS UI LXC. Proceed(y/n)?" yn
|
||||||
case $yn in
|
case $yn in
|
||||||
[Yy]* ) break;;
|
[Yy]* ) break;;
|
||||||
[Nn]* ) exit;;
|
[Nn]* ) exit;;
|
||||||
@ -51,7 +51,7 @@ function cleanup() {
|
|||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd $TEMP_DIR >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
|
|
||||||
TITLE="Zigbee2MQTT LXC Data Copy"
|
TITLE="Zigbee2MQTT to Z-wave JS UI Data Copy"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo "$line" | awk '{print $1}')
|
||||||
ITEM=$(echo "$line" | awk '{print substr($0,36)}')
|
ITEM=$(echo "$line" | awk '{print substr($0,36)}')
|
||||||
@ -69,7 +69,7 @@ while [ -z "${CTID_FROM:+x}" ]; do
|
|||||||
done
|
done
|
||||||
while [ -z "${CTID_TO:+x}" ]; do
|
while [ -z "${CTID_TO:+x}" ]; do
|
||||||
CTID_TO=$(whiptail --title "$TITLE" --radiolist \
|
CTID_TO=$(whiptail --title "$TITLE" --radiolist \
|
||||||
"\nWhich Zwavejs2MQTT LXC would you like to copy TO?\n" \
|
"\nWhich Z-wave JS UI LXC would you like to copy TO?\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
||||||
done
|
done
|
||||||
@ -82,7 +82,7 @@ done
|
|||||||
whiptail --defaultno --title "$TITLE" --yesno \
|
whiptail --defaultno --title "$TITLE" --yesno \
|
||||||
"Are you sure you want to copy data between the following LXCs?
|
"Are you sure you want to copy data between the following LXCs?
|
||||||
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
|
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
|
||||||
Version: 2022.03.06" 13 50 || exit
|
Version: 2022.09.21" 13 50 || exit
|
||||||
info "Zwavejs2MQTT Data from '$CTID_FROM' to '$CTID_TO'"
|
info "Zwavejs2MQTT Data from '$CTID_FROM' to '$CTID_TO'"
|
||||||
if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then
|
if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then
|
||||||
msg "Stopping '$CTID_TO'..."
|
msg "Stopping '$CTID_TO'..."
|
||||||
@ -90,13 +90,14 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then
|
|||||||
fi
|
fi
|
||||||
msg "Mounting Container Disks..."
|
msg "Mounting Container Disks..."
|
||||||
DATA_PATH=/opt/zwavejs2mqtt/store/
|
DATA_PATH=/opt/zwavejs2mqtt/store/
|
||||||
|
DATA_PATH_NEW=/opt/zwave-js-ui/store/
|
||||||
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \
|
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \
|
||||||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
|
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
|
||||||
[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \
|
[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \
|
||||||
die "Zwavejs2MQTT directories in '$CTID_FROM' not found."
|
die "Zwavejs2MQTT directories in '$CTID_FROM' not found."
|
||||||
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \
|
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \
|
||||||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
|
die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
|
||||||
[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || \
|
[ -d "${CTID_TO_PATH}${DATA_PATH_NEW}" ] || \
|
||||||
die "Zwavejs2MQTT directories in '$CTID_TO' not found."
|
die "Zwavejs2MQTT directories in '$CTID_TO' not found."
|
||||||
|
|
||||||
#rm -rf ${CTID_TO_PATH}${DATA_PATH}
|
#rm -rf ${CTID_TO_PATH}${DATA_PATH}
|
||||||
@ -111,8 +112,8 @@ RSYNC_OPTIONS=(
|
|||||||
--no-inc-recursive
|
--no-inc-recursive
|
||||||
--info=progress2
|
--info=progress2
|
||||||
)
|
)
|
||||||
msg "<======== Zwavejs2MQTT Data ========>"
|
msg "<======== Zwavejs Data ========>"
|
||||||
rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${DATA_PATH} ${CTID_TO_PATH}${DATA_PATH}
|
rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${DATA_PATH} ${CTID_TO_PATH}${DATA_PATH_NEW}
|
||||||
echo -en "\e[1A\e[0K\e[1A\e[0K"
|
echo -en "\e[1A\e[0K\e[1A\e[0K"
|
||||||
|
|
||||||
info "Successfully Transferred Data."
|
info "Successfully Transferred Data."
|
||||||
|
Loading…
Reference in New Issue
Block a user