Linux daemon to run scheduled backups of virtual machines using libvirt. Currently this only supports qemu/kvm.
- libvirt-dev
sudo apt install libvirt-devThis is meant to be run as a systemd service and configured via config yaml.
There are couple behaviors which are expected but might come as a surprise.
First backup of the day is named as /backupdir/<vm-name>/dd-mm-yyyy_disk.qcow2 and any subsequent backups for the day are named as /backupdir/<vm-name>/dd-mm-yyyy_disk_XX.qcow2 where XX is any number starting from 1. This leads to only the first backup of the day to be saved and all other backups of the day to be pruned. This behavior is expected and originates from pruning being done via constructing the file names which are to be saved. This might change later but for now this is the way.
Install using the install.sh script.
# Install latest verstion
sudo curl -o- https://raw.githubusercontent.com/Ben-PP/libvirt-backup/refs/heads/main/install.sh | bash
# Or specific version (check releases for available versions)
sudo curl -o- https://raw.githubusercontent.com/Ben-PP/libvirt-backup/refs/heads/main/install.sh | bash -s -- <version>To update you can just run the install script again. It will leave the default config.yaml if it exists already.
To uninstall you can use the uninstall.sh if you installed using the script or used the default locations and names for everything.
sudo curl -o- https://raw.githubusercontent.com/Ben-PP/libvirt-backup/refs/heads/main/uninstall.sh | bashThese are the manual steps to get the program running. Install script should be preferred so these are not very specific instructions.
Config is read from /etc/libvirt-backup/config.yaml by default, but this can be changed with -c flag. Create the config file and use the config.example.yaml as a base.
sudo mkdir /etc/libvirt-backup
sudo touch /etc/libvirt-backup/config.yaml
# Fill in the configIn the config file backup-dir key defines the directory under which all of the backups will be stored. This can be any directory you like, but be mindful of the fact that the directory will be chowned to libvirt-qemu:kvm and if it does not exist, it will be created.
Add the binary to /usr/local/sbin.
Remember to allow execution.
sudo chmod 700 /usr/local/sbin/libvirt-backupThis program is meant to be run as a systemd service. Create a service file for it. You can use the provided libvirt-backup.service.