Closed chrcoluk closed 1 year ago
Hi, you can run everywhere.
Best regards
Hi, to achieve redundancy, this is what I'm doing:
/opt/tools/bin/cv4pve-autosnap (binary)
/opt/tools/etc/cron.d/cv4pve-autosnap (crontab file)
/opt/tools/scripts/cv4pve-autosnap.sh (shell script)
ln -s /opt/tools/etc/cron.d/cv4pve-autosnap /etc/cron.d/
(syncthing.net -> apt-get install syncthing, enable it and configure)
#!/bin/bash
if [[ -z "$2" ]]; then
echo "Usage: $(basename $0) <label> <# keep> [all]"
exit 1
fi
snapshot_user="autosnap@pve"
snapshot_password="XXXXXXXXXXX"
label="$1"
keep="$2"
[[ -z "$3" ]] && what="all" || what="$3"
# Only run if this host is the cluster master
is_master=$(/usr/sbin/ha-manager status | grep -m 1 -o "^master $(hostname -s)")
if [[ ! -z "${is_master}" ]]; then
/opt/tools/bin/cv4pve-autosnap \
--host=127.0.0.1 \
--username=${snapshot_user} \
--password=${snapshot_password} \
--vmid="${what}" \
snap \
--label="${label}" \
--keep="${keep}" \
--only-running
fi
# Snapshot
0 0 * * * root /opt/tools/scripts/cv4pve-autosnap.sh daily 5 all
0 */1 * * * root /opt/tools/scripts/cv4pve-autosnap.sh hourly 8 all
This is far from the best way to do it probably, but it works for me :)
You can run cv4pve-autosnap outside the cluster or in a vm or ct.
It seems to be a requirement to run it remotely.