From 320c00179eda8ee6aed07482dd5269d9c03f3c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Wed, 22 Apr 2026 14:19:34 -0400 Subject: [PATCH] be smart: only snapshot running domains when in live mode --- src/bin/snapshot-libvirt-domains | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bin/snapshot-libvirt-domains b/src/bin/snapshot-libvirt-domains index 0d5c5dc..e3cb29d 100755 --- a/src/bin/snapshot-libvirt-domains +++ b/src/bin/snapshot-libvirt-domains @@ -62,7 +62,13 @@ fi zfs_autobackup_args+=("--no-send" "--no-thinning") zfs_autobackup_args+=("--snapshot-format" "libvirt-%Y-%m-%d-%H:%M:%S") -for domain in $(virsh list --name); do +declare -a virsh_args=() +if [ "$live" -eq 1 ]; then + virsh_args+=("--state-running") +else + virsh_args+=("--all") +fi +for domain in $(virsh list --name "${virsh_args[@]}"); do if [ "$(zfs get -t filesystem,volume autobackup:libvirt-${domain} -o value -H -s local)" == "" ]; then echo "Skipping domain ${domain} because it is not configured for autobackup" >&2 continue