Set up systemd service and timer for backups

This commit is contained in:
Râu Cao
2022-10-21 10:50:04 +02:00
parent 95941c830f
commit 61710aa4a4
4 changed files with 49 additions and 0 deletions

View File

@@ -54,3 +54,39 @@ template "/root/backups/backup_all_vms.sh" do
mode '0750'
variables vm_domains: vm_domains
end
systemd_unit "backup-libvirt-guests.service" do
content({
Unit: {
Description: "Back up libvirt guest images and metadata",
Wants: "network.target"
},
Service: {
Type: "oneshot",
EnvironmentFile: "/root/.borg_credentials.env",
ExecStart: "/root/backups/backup_all_vms.sh",
SyslogIdentifier: "backup-libvirt-guests",
Restart: "no"
}
})
verify false
triggers_reload true
action [:create]
end
systemd_unit "backup-libvirt-guests.timer" do
content({
Unit: {
Description: "Back up libvirt guest images and metadata",
},
Timer: {
OnCalendar: node["kosmos_kvm"]["backup"]["schedule"]
},
Install: {
WantedBy: "timers.target"
}
})
verify false
triggers_reload true
action [:create, :enable, :start]
end