4 Commits

Author SHA1 Message Date
Râu Cao
6d765f959d Fix backup VM name for ldap-3
(and potentially other guests where the name differs from the libvirt
domain name)
2022-10-19 12:51:46 +02:00
Râu Cao
82f50b0caa Only back up domain-specific XML per archive 2022-10-19 12:24:10 +02:00
Râu Cao
6c8f9055c1 Create directories for KVM host backup files 2022-10-19 12:23:54 +02:00
Râu Cao
2e2ebbcc02 Fix filenames for guest agent sockets 2022-10-19 12:23:17 +02:00
3 changed files with 11 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ virsh snapshot-create-as --domain $1 \
borg create -v --stats \
$REPOSITORY::$1_$(date +%F_%H-%M) \
/var/lib/libvirt/images/$1.qcow2 \
/root/backups/vm_meta
/root/backups/vm_meta/$1.xml
echo "Pivoting base image back to original"
virsh blockcommit $1 vda --pivot --base=/var/lib/libvirt/images/$1.qcow2

View File

@@ -24,13 +24,21 @@ export BORG_REPO='#{borg_credentials["repository"]}'
not_if "grep -q BORG /root/.bashrc"
end
directory "/root/backups" do
mode "0750"
end
directory "/root/backups/vm_meta" do
mode "0750"
end
cookbook_file "/root/backups/backup_vm.sh" do
source "backup_vm.sh"
mode "0750"
end
# Search all guests and filter by presence on current host
vm_domains = search(:node, "role:kvm_guest").map(&:name) \
vm_domains = search(:node, "role:kvm_guest").map{|n| n["hostname"] } \
& `virsh list --name`.strip.chomp.split("\n")
template "/root/backups/backup_all_vms.sh" do

View File

@@ -86,6 +86,6 @@ virt-install \
--graphics none \
--serial pty \
--console pty \
--channel unix,mode=bind,path=/var/lib/libvirt/qemu/guest01.agent,target_type=virtio,name=org.qemu.guest_agent.0 \
--channel unix,mode=bind,path=/var/lib/libvirt/qemu/$VMNAME.guest_agent.0,target_type=virtio,name=org.qemu.guest_agent.0 \
--autostart \
--import