{"id":7843,"date":"2019-02-08T13:26:49","date_gmt":"2019-02-08T03:26:49","guid":{"rendered":"https:\/\/nsrd.info\/blog\/?p=7843"},"modified":"2019-02-08T13:26:56","modified_gmt":"2019-02-08T03:26:56","slug":"updated-kvm-image-backup-script-for-networker","status":"publish","type":"post","link":"https:\/\/nsrd.info\/blog\/2019\/02\/08\/updated-kvm-image-backup-script-for-networker\/","title":{"rendered":"Updated KVM Image Backup Script for NetWorker"},"content":{"rendered":"\n<p>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 <em>and<\/em> the backups are tagged appropriately.<\/p>\n\n\n\n<p>I&#8217;ve updated that script now and the configuration to more readily support a &#8216;clustered&#8217; virtual machine configuration \u2013\u00a0i.e., dealing with the possibility that virtual machines may move between different individual KVM servers, while ensuring that they&#8217;re still readily recoverable without having to remember what KVM server a virtual machine was running on at any given time.<\/p>\n\n\n\n<p>In order to support this, I&#8217;ve used NetWorker&#8217;s <em>cluster<\/em> client configuration. In my case, I don&#8217;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.<\/p>\n\n\n\n<p>In my case, my single KVM server is called <em>oa<\/em>, 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&#8217;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 &#8216;dummy&#8217; client called <em>ballybran<\/em>, then used the NetWorker create client option in NMC (rather than the client creation <em>wizard<\/em>, which requires a real client to connect to), and setup a simple client entry in NetWorker.<\/p>\n\n\n\n<p>This &#8216;fake&#8217; client doesn&#8217;t actually get backed up, of course \u2013\u00a0but 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 &#8220;Globals (2 of 2)&#8221; properties pane for the client. In this case, you want to add root@<em>hostname<\/em> for each of the <em>actual<\/em> KVM servers in your environment to the list. For me, that looked like the following:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"794\" height=\"634\" src=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/KVM-Cluster-Configuration.png\" alt=\"\" class=\"wp-image-7844\" srcset=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/KVM-Cluster-Configuration.png 794w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/KVM-Cluster-Configuration-300x240.png 300w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/KVM-Cluster-Configuration-768x613.png 768w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/KVM-Cluster-Configuration-250x200.png 250w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><figcaption>Enabling a &#8216;cluster&#8217; client configuration for KVM backups<\/figcaption><\/figure>\n\n\n\n<p>When we want to have a client backup data <em>on\u00a0behalf\u00a0of<\/em> another client, or rather, <em>tagging<\/em> the backup as belonging to another client, we invoke save with a -C client option, which is what I&#8217;ve added to the savekvm script (link further below). To facilitate this option in the savekvm script, I&#8217;ve introduced the option to specify a tagged client, or cluster client, if you will, via the &#8220;-c clientName&#8221; option. So in this case, the backup command might look like the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <strong>savekvm.pl -r 7 -b BoostBackup -s orilla -c ballybran<\/strong><\/pre>\n\n\n\n<p>In this case, that means do a backup to the pool &#8220;BoostBackup&#8221; (remember NetWorker always specifies pool via a -b option, which I carry through to my scripts), using the NetWorker server <em>orilla<\/em>, and writing the backups tagged to the client <em>ballybran<\/em>. Post backup, mminfo shows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"343\" src=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/mminfo_ballybran.png\" alt=\"\" class=\"wp-image-7845\" srcset=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/mminfo_ballybran.png 800w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/mminfo_ballybran-300x129.png 300w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/mminfo_ballybran-768x329.png 768w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/mminfo_ballybran-466x200.png 466w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Backups tagged for &#8216;cluster&#8217; KVM server<\/figcaption><\/figure>\n\n\n\n<p>The only change this makes from a recovery perspective is to make sure you invoke the recovery against the erstwhile cluster client \u2013\u00a0for instance:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"804\" height=\"724\" src=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/relocated_recovery.png\" alt=\"\" class=\"wp-image-7846\" srcset=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/relocated_recovery.png 804w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/relocated_recovery-300x270.png 300w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/relocated_recovery-768x692.png 768w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/relocated_recovery-222x200.png 222w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><figcaption>Recovering a &#8216;cluster&#8217; KVM image based backup<\/figcaption><\/figure>\n\n\n\n<p>That&#8217;s all there is to it. For more details of the overall process, <strong><a rel=\"noreferrer noopener\" aria-label=\"check out the original post (opens in a new tab)\" href=\"https:\/\/nsrd.info\/blog\/2018\/11\/06\/a-simple-linux-kvm-backup-framework-using-networker\/\" target=\"_blank\">check out the original post<\/a><\/strong> from November, and you can find the <a href=\"https:\/\/nsrd.info\/scripts\/savekvm.zip\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"updated script here (opens in a new tab)\">updated script here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In November last year I posted a script and descriptions for use to allow NetWorker to backup RedHat\/CentOS KVM images&hellip;<\/p>\n","protected":false},"author":1,"featured_media":7844,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,6,12,16,20],"tags":[138,1487,1249],"class_list":["post-7843","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-architecture","category-basics","category-general-technology","category-networker","category-scripting","tag-backup","tag-kvm","tag-networker"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2019\/02\/KVM-Cluster-Configuration.png","jetpack_shortlink":"https:\/\/wp.me\/pKpIN-22v","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/7843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/comments?post=7843"}],"version-history":[{"count":2,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/7843\/revisions"}],"predecessor-version":[{"id":7848,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/7843\/revisions\/7848"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/media\/7844"}],"wp:attachment":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/media?parent=7843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/categories?post=7843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/tags?post=7843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}