KVM Plugin Bacula Enterprise Quick Guide


This Quick Guide presents various techniques KVM virtual machines Backup with the Enterprise Bacula (EBacula) exclusive plugin, that provide the following features, among others:

  • Clientless Virtual Machines (VMs) Backup
  • Granular File-Level Recovery
  • Automatic VMs discovery
  • Full, Differential, and Incremental Backup Level Support
  • VMs Backup in ’running’, ’paused’ or even ’shut off’ States
  • The Ability to Include or Exclude Files from the VM Backup

The KVM plugin is designed to be used when the hypervisor uses local storage for virtual machine disks and libvirtd for virtual machine management. However, EBacula has also other specific plugins for Proxmox, Redhat RHEV/Ovirt, and OpenStack.


Install the EBacula backup Client, Libs, and the KVM package in your hypervisor. Consider the Linux distribution, version and, architecture, such as in:

rpm -ivh install bacula-enterprise-libs-10.0.5-1.el7.x86_64.rpm 
rpm -ivh install bacula-enterprise-client-10.0.5-1.el7.x86_64.rpm  
rpm -ivh install bacula-enterprise-kvm-plugin-10.0.5-1.el7.x86_64.rpm

Remark: the KVM Plugin uses snapshots while backing up guest VMs. During a snapshot, blocks modified by the guest VM need to be copied in temporary space, the space
required depends on the guest disk activity. By default, space is allocated under /var/tmp, so make sure there is some room for that.

Virtualization tools (qemu-ga) must be installed on the guest and you may have to configure the guest VMs to quiesce the file system properly during the snapshot phase.


Backup Client

The libvirtd daemon should be started and accessible. The KVM hypervisor server’s File Daemon should have local, network-mounted, or SAN access to where KVM images are stored. On the KVM host server, the following command should list all local VMs:

# virsh list --all
Id Name State
1 gentoo running
2 centos paused
- debian shut off

If the specification of a URI using virsh’s -c parameter is required, the corresponding uri= parameter will also be needed in the plugin command explained later.

# virsh -c qemu:///system list --all
Id Name State
1 gentoo running
2 centos paused
- debian shut off

The install-kvm.sh script is designed to test the KVM setup of the hypervisor. The script should report an “OK” at the end as in the example. If not, contact your support.

# /opt/bacula/scripts/install-kvm.sh check
Enter the libvirt URI to connect libvirtd [qemu:///system]:
Trying to list VMs using virsh -r -c 'qemu:///system' list --all, it should not ask for a password.
Id Name State
1 gentoo running
2 centos paused
- debian shut off
Did you have to enter a password to get the VM list? [y/N]: N
Enter the name of a guest that will be used to test the KVM plugin requirements:
Trying to mount gentoo filesystem as /tmp/bee-kvm-gentoo.2vsYz
Mount OK.
Attempting to list 10 files from gentoo root filesystem.
Unmounting gentoo filesystem.
OK: All tests are good.

Prepare you Client for Director connection (set you actual Director Name on bacula-fd.conf, copy and paste the password for Director attachment). Restart the Bacula Client to apply changes.

Bacula Director

Attach the Client to the Director (create a new Client configuration resource using the Password copied from the last step).

Create a new FileSet with the desired KVM plugin Options. Figure 1 example will backup all hypervisor VMs. You can use BWeb GUI if desired.

KVM Plugin Bacula Enterprise Quick Guide 1

Figure 1. A KVM Plugin Configuration to Backup All VMs

In this second example, it is possible o include specific VMs for this FileSet:

FileSet {
  Name = FS_KVM
    Include {
      Options {
        Signature = MD5
        Compression = LZO
    Plugin = "kvm: host=centos,gentoo"

If one FileSet backups several VMs, they will appear in the restore file selection tree with the VM name as the first directory for restore, such as the following:

* list files jobid=100
| filename |
| ...                             |
| /centos/boot                    |
| /centos/boot/grub               |
| /centos/boot/grub/menu.lst      |
| ...                             | 
| /gentoo/etc/passwd              |
| /gentoo/etc/group               |
| /gentoo/etc/hosts               |
| ...                             |
+ --------------------------------+

If a KVM FileSet contains only one virtual machine, each file’s path will not be prefixed with the virtual machine’s name, as shown below. This default behavior can be overridden by using the host_prefix KVM plugin parameter. The following FileSet:

FileSet {
  Name = FS_KVM_centos
   Include {
     Plugin = "kvm: host=centos"

Will result in the following list jobs bconsole command output:

* list files jobid=101
| filename |
| ...                             |
| /boot                           |
| /boot/grub                      |
| /boot/grub/menu.lst             |
| ...                             |
+ --------------------------------+

The FileSet Include and Exclude for files or directories selection is ignored when using the KVM plugin. To Include or Exclude specific directories, the next example should be used.

FileSet {
  Name = FS_KVM_etc_home
    Include {
      Plugin = "kvm: host=centos include=/etc include=/home exclude=/home/tmp"

The current Plugin options are detailed as follows:

uriThe URI parameter specifies how to connect to the hypervisor. The documentation page at http://libvirt.org/uri.html list the supported values.
hostVirtual Machine to be backed up. It is possible to specify a list of hosts separated by a ’,’ (without spaces).
includeSpecify files or directories to backup. It is possible to specify multiple include= parameters in the plugin command line.
excludeSpecify files or directories to exclude. It is possible to specify multiple exclude= parameters in the plugin command line.
host_prefixNoPrefix all files with the virtual machine name (mandatory when doing multiple virtual machines backup in the same job).
host_sep,Specify a host separator used in the host parameter. host_sep=: host=h1:h2:h3
abort_on_errorNoAbort the job if an error is occurring during the job. By default, if a VM is not accessible for example, the Job will end with JobStatus OK (T) and some JobErrors.

Create a new backup Job using the KVM client and the new FileSet. Reload or restart the Director daemon to apply changes.


To restore a file, simply use the bconsole restore command, select the backup Job and run a traditional restore Job.


  • When doing a backup at the KVM domain controller (hypervisor) level, some Bacula features such as client RunScripts are not supported. Dumping a MySQL database on a guest VM before the backup will require the use of custom scripts, using SSH for example, os installing a Bacula Client inside the VM operating system.
  • CD ROMS must be disconnected from VMs before attempting a backup with the KVM plugin. Else, the system might report


  1. KVM Plugin Using Bacula Enterprise Edition Whitepaper, Bacula Systems. http://baculasystems.com

Disponível em: pt-brPortuguês (Portuguese (Brazil)) enEnglish esEspañol (Spanish)

Leave a Reply

Close Menu