Updated KVM Image Backup Script for NetWorker

In November last year I posted a script and descriptions for use to allow NetWorker to backup RedHat/CentOS KVM images in such a way that the configuration file and virtual disk files are backed up and the backups are tagged appropriately.

I’ve updated that script now and the configuration to more readily support a ‘clustered’ virtual machine configuration – i.e., dealing with the possibility that virtual machines may move between different individual KVM servers, while ensuring that they’re still readily recoverable without having to remember what KVM server a virtual machine was running on at any given time.

In order to support this, I’ve used NetWorker’s cluster client configuration. In my case, I don’t have a cluster of hosts running virtual machines, just a single KVM server. But it was relatively straight-forward to envisage the configuration and adapt the script accordingly.

In my case, my single KVM server is called oa, but I imagined a scenario where I might have multiple KVM hosts with virtual machines potentially moving around between them. To handle the backups, you’d want to tag the virtual machines as being from a single resource. So, I created a new DNS entry (you could use /etc/hosts) for a ‘dummy’ client called ballybran, then used the NetWorker create client option in NMC (rather than the client creation wizard, which requires a real client to connect to), and setup a simple client entry in NetWorker.

This ‘fake’ client doesn’t actually get backed up, of course – but we do want to make sure that the KVM server(s) in the environment can backup on behalf of the client, and you do that from the “Globals (2 of 2)” properties pane for the client. In this case, you want to add root@hostname for each of the actual KVM servers in your environment to the list. For me, that looked like the following:

Enabling a ‘cluster’ client configuration for KVM backups

When we want to have a client backup data on behalf of another client, or rather, tagging the backup as belonging to another client, we invoke save with a -C client option, which is what I’ve added to the savekvm script (link further below). To facilitate this option in the savekvm script, I’ve introduced the option to specify a tagged client, or cluster client, if you will, via the “-c clientName” option. So in this case, the backup command might look like the following:

# savekvm.pl -r 7 -b BoostBackup -s orilla -c ballybran

In this case, that means do a backup to the pool “BoostBackup” (remember NetWorker always specifies pool via a -b option, which I carry through to my scripts), using the NetWorker server orilla, and writing the backups tagged to the client ballybran. Post backup, mminfo shows:

Backups tagged for ‘cluster’ KVM server

The only change this makes from a recovery perspective is to make sure you invoke the recovery against the erstwhile cluster client – for instance:

Recovering a ‘cluster’ KVM image based backup

That’s all there is to it. For more details of the overall process, check out the original post from November, and you can find the updated script here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.