evobackup/lib/bkctld-sync

31 lines
980 B
Plaintext
Raw Normal View History

2019-01-04 13:51:05 +01:00
#!/bin/sh
#
# Sync jail <jailname> or all to another node
# Usage: sync <jailname>|all
#
2019-01-04 13:51:05 +01:00
2020-04-02 13:44:13 +02:00
# shellcheck source=./includes
2020-04-02 00:31:57 +02:00
LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes"
2019-01-04 13:51:05 +01:00
2020-04-02 13:44:13 +02:00
jail_name="${1:?}"
2020-04-02 01:07:12 +02:00
if [ -z "${jail_name}" ]; then
"${LIBDIR}/bkctld-help" && exit 1
fi
2020-04-02 01:07:12 +02:00
jail_path=$(jail_path "${jail_name}")
test -d "${jail_path}" || error "${jail_name}: jail is missing."
2019-01-04 13:51:05 +01:00
[ -n "${NODE}" ] || error "Sync need config of \$NODE in /etc/default/bkctld !"
2020-04-02 01:07:12 +02:00
ssh "${NODE}" "${LIBDIR}/bkctld-init" "${jail_name}" | debug
rsync -a "${jail_path}/" "${NODE}:${jail_path}/" --exclude proc/* --exclude sys/* --exclude dev/* --exclude run --exclude var/backup/*
rsync -a "${CONFDIR}/${jail_name}" "${NODE}:${CONFDIR}/${jail_name}"
"${LIBDIR}/bkctld-is-on" "${jail_name}" && ssh "${NODE}" "${LIBDIR}/bkctld-start" "${jail_name}" | debug
2019-01-04 13:51:05 +01:00
if [ -n "${FIREWALL_RULES}" ]; then
rsync -a "${FIREWALL_RULES}" "${NODE}:${FIREWALL_RULES}"
ssh "${NODE}" /etc/init.d/minifirewall restart | debug
fi