{"id":10572,"date":"2021-08-16T15:55:46","date_gmt":"2021-08-16T05:55:46","guid":{"rendered":"https:\/\/nsrd.info\/blog\/?p=10572"},"modified":"2021-08-16T15:55:49","modified_gmt":"2021-08-16T05:55:49","slug":"networker-basics-rolling-your-own-savesets","status":"publish","type":"post","link":"https:\/\/nsrd.info\/blog\/2021\/08\/16\/networker-basics-rolling-your-own-savesets\/","title":{"rendered":"NetWorker Basics \u2013\u00a0Rolling your own Savesets"},"content":{"rendered":"\n<p>One of NetWorker&#8217;s power-user features is the option to name a saveset. This is most commonly used by Windows disaster recovery savesets and database savesets, but you can specify your own if you need to.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Why would you need to name savesets?<\/p><p>Example: I made use of this in the process I outlined for backups of <strong><a href=\"https:\/\/nsrd.info\/blog\/2018\/11\/06\/a-simple-linux-kvm-backup-framework-using-networker\/\" target=\"_blank\" rel=\"noreferrer noopener\">Linux KVM guests<\/a><\/strong>. (Using the -N <em>savesetName<\/em> option in NetWorker, my script generated saveset names of <em>hypervisor:<\/em>KVM<em>:guestName:diskName<\/em>, making it easy to identify KVM backups in the mminfo output.)<\/p><\/blockquote>\n\n\n\n<p>Let&#8217;s have another look at how you can make use of named savesets to beef up your recovery options using Linux.<\/p>\n\n\n\n<p>When I used to be a Unix systems administrator, our team had scripts that ran on all the hosts we were responsible for, building up all the system rebuild data we might need in an emergency \u2013 copies of the filesystem tables, disk layouts, network configuration and a myriad of other details. (At the time, these were printed and stored for several months.)<\/p>\n\n\n\n<p>So in this example, I&#8217;m going to outline a scenario of gathering critical rebuild information for systems and sending that data to NetWorker with a saveset name that makes it very clear what it is. The process will look like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A &#8216;critical rebuild&#8217; script is copied onto the backup client.<\/li><li>Backup client is configured with:<ul><li>Save set of &#8216;All&#8217;<\/li><li>Pre-command that runs the &#8216;critical rebuild&#8217; script with arguments for pool, server and expiration date.<\/li><\/ul><\/li><li>Policy\/workflow runs:<ul><li>Pre-command generates the critical rebuild information<\/li><li>Pre-command runs a manual backup with the required details, naming the manual saveset for easy identification<\/li><li>Backup runs.<\/li><\/ul><\/li><\/ul>\n\n\n\n<p>So let&#8217;s start with the backup script:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-\">#!\/bin\/bash\n\nPATH=\/bin:\/sbin:\/usr\/bin:\/usr\/sbin\nexport PATH\n\nRebuildDir=\/critrebuild\nSERVER=null\nPOOL=null\nEXP=null\nHOST=`hostname`\n\nwhile getopts s:b:e: flag\ndo\n\tcase \"${flag}\" in\n\t\ts) SERVER=${OPTARG};;\n\t\tb) POOL=${OPTARG};;\n\t\te) EXP=${OPTARG};;\n\tesac\ndone\n\nif [ \"$SERVER\" = \"null\" ] || [ \"$POOL\" = \"null\" ] || [ \"$EXP\" = \"null\" ]\nthen\n\techo \"Your must specify -s server -b pool -e expiration\"\n\texit 1\nfi\n\nif [ ! -d $RebuildDir ]\nthen\n\techo You need to create $RebuildDir\n\texit 1\nelse\n\t# Let's get a start on.\n\tenv > $RebuildDir\/run_env.txt\n\trpm --query -a > $RebuildDir\/rpm_query_a.txt\n\tfdisk -l > $RebuildDir\/fdisk_l.txt\n\tmount > $RebuildDir\/mount.txt\n\tcat \/proc\/mdstat > $RebuildDir\/mdstat.txt\n\tifconfig -a > $RebuildDir\/ifconfig_a.txt\n\tnetstat -ar > $RebuildDir\/netstat_ar.txt\n\tlvm fullreport > $RebuildDir\/lvm_fullreport.txt\n\tsystemctl > $RebuildDir\/systemctl_list.txt\n\n\tsave -s $SERVER -b \"${POOL}\" -e \"+${EXP} days\" -N ${HOST}:CRITREBUILD $RebuildDir\nfi<\/code><\/pre>\n\n\n\n<p>I&#8217;ve called the script &#8216;nsrcritrebuild.sh&#8217; and symbolically linked it to <strong>\/usr\/bin\/nsrcritrebuild.sh<\/strong>. (This puts it in the same directory as the NetWorker save command.) Assuming you have a directory of \/critrebuild on the server, the command generates the following information:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A list of installed packages<\/li><li>Partition maps<\/li><li>Mounted disks<\/li><li>Details for any Linux software-RAID volumes<\/li><li>Network configuration details and default routing<\/li><li>Details of any Linux Volume Manager configuration<\/li><li>Service information<\/li><\/ul>\n\n\n\n<p>The command should be invoked as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <strong>nsrcritrebuild.sh -s <em>backupServer<\/em> -b <em>poolName<\/em> -e <em>expirationInDays<\/em><\/strong><\/pre>\n\n\n\n<p>(If you&#8217;re wondering why I use -b <em>poolName<\/em> rather than -p <em>poolName<\/em>, it&#8217;s because NetWorker uses -b for the pool in commands like <em>save<\/em>.)<\/p>\n\n\n\n<p>So, if I wanted to generate a critical rebuild dataset and write it to the backup server orilla using the pool Backup_01 and keep it for 31 days, I&#8217;d invoke the command as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <strong>nsrcritrebuild.sh -s orilla -b Backup_01 -e 31<\/strong><\/pre>\n\n\n\n<p>Once the file is in place on the client and the \/critrebuild directory created, I can set it up within NetWorker. To do that, I need to define the pre-command correctly. Using the NWUI, you can see it as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildconfig.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1515\" height=\"576\" src=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildconfig.png\" alt=\"Creating a special saveset via a pre-command.\" class=\"wp-image-10576\" srcset=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildconfig.png 1515w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildconfig-300x114.png 300w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildconfig-1024x389.png 1024w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildconfig-768x292.png 768w\" sizes=\"auto, (max-width: 1515px) 100vw, 1515px\" \/><\/a><figcaption><strong><em>Invoking the critical rebuild info script as a pre-command<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<p>Once the critical rebuild script gathers the data, it fires off a manual saveset to the backup server, naming the saveset <em>hostname<\/em>:CRITREBUILD. For my client, &#8216;totesrhelly&#8217;, that means if I do a mminfo query for its savesets, I get clear details of the rebuild saveset:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildmminfo-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1810\" height=\"1174\" src=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildmminfo-2.png\" alt=\"Special saveset shown in mminfo output.\" class=\"wp-image-10581\" srcset=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildmminfo-2.png 1810w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildmminfo-2-300x195.png 300w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildmminfo-2-1024x664.png 1024w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildmminfo-2-768x498.png 768w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critrebuildmminfo-2-1536x996.png 1536w\" sizes=\"auto, (max-width: 1810px) 100vw, 1810px\" \/><\/a><figcaption><strong><em>Critical Rebuild Saveset in mminfo output<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<p>So, in addition to a &#8216;\/&#8217; saveset, and a &#8216;\/boot&#8217; saveset, I&#8217;ve got a <strong>totesrhelly.turbamentis.int:CRITREBUILD<\/strong> saveset. Now, you might argue that anyone wanting the critical-rebuild data can just recover the \/critrebuild directory from the client as part of a normal filesystem recovery \u2013\u00a0and you&#8217;d be right! But you&#8217;ve now got it also easily identified as a <strong><em>specific <\/em><\/strong>saveset making it easy for <em>anyone<\/em> to see. For instance, if you&#8217;re in the NetWorker Management Console recovery interface and looking at recoverable savesets, you&#8217;ll see:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critical-rebuild-saveset-in-NMC.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1086\" height=\"905\" src=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critical-rebuild-saveset-in-NMC.png\" alt=\"Special savesets shown in NMC recovery window.\" class=\"wp-image-10582\" srcset=\"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critical-rebuild-saveset-in-NMC.png 1086w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critical-rebuild-saveset-in-NMC-300x250.png 300w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critical-rebuild-saveset-in-NMC-1024x853.png 1024w, https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2021\/08\/critical-rebuild-saveset-in-NMC-768x640.png 768w\" sizes=\"auto, (max-width: 1086px) 100vw, 1086px\" \/><\/a><figcaption><strong><em>Critical Rebuild Saveset Visibility in NMC<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<p>This also means you can build your recovery process, if you&#8217;d like, around the named saveset. For instance:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@totesrhelly \/]# <strong>mminfo -s orilla -q \"name=totesrhelly.turbamentis.int:CRITREBUILD,savetime&gt;=24 hours ago\"<\/strong>\n volume        client       date      size   level  name\nBackup01       totesrhelly.turbamentis.int 15\/08\/21 66 KB manual totesrhelly.turbamentis.int:CRITREBUILD\n[root@totesrhelly \/]# <strong>mminfo -s orilla -q \"name=totesrhelly.turbamentis.int:CRITREBUILD,savetime&gt;=24 hours ago\" -r ssid<\/strong>\n2434297097\n[root@totesrhelly \/]# <strong>recover -s orilla -iN -d \/tmp\/critrebuild -S 2434297097<\/strong>\n179040:recover: Step (1 of 11) for PID-8458: Recovery has been started on the client 'totesrhelly.turbamentis.int'.\n179732:recover: Step (2 of 11) for PID-8458: Checking if the set of exclusion files is given for the recovery of the save set '2434297097' for the client 'totesrhelly.turbamentis.int'.\n179737:recover: Step (3 of 11) for PID-8458: Setting the server 'orilla' for the media database calls for the recovery of the save set '2434297097' for the client 'totesrhelly.turbamentis.int'.\n179742:recover: Identified a file system recovery with PID 8458 for the relocated recovery of the save set '2434297097' for the client 'totesrhelly.turbamentis.int'. Updating the total number of steps from 11 to 10.\n179044:recover: Step (4 of 10) for PID-8458: Checking if the save set ID '2434297097' given for recovery is valid or not for the client 'totesrhelly.turbamentis.int'.\n179045:recover: Step (5 of 10) for PID-8458: Fetching the save set record for the given save set ID '2434297097'for the client 'totesrhelly.turbamentis.int'.\n179748:recover: Step (6 of 10) for PID-8458: Initializing a recovery job with the nsrjobd for the recovery of the selected file(s) for the client 'totesrhelly.turbamentis.int'.\n179749:recover: Step (7 of 10) for PID-8458: Validating and setting the relocation path '\/tmp\/critrebuild' for the recovery of selected file(s) for the client 'totesrhelly.turbamentis.int'.\n184407:recover: Step (8 of 10) for PID-8458: Validating whether the save set 'totesrhelly.turbamentis.int:CRITREBUILD' with save set ID \t\t\t\t\t\t'2434297097' is block based recoverable for the client 'totesrhelly.turbamentis.int'.\n184408:recover: Step (9 of 10) for PID-8458: Initializing the file system save set recovery for \t\t\tthe save set 'totesrhelly.turbamentis.int:CRITREBUILD' with the save set ID '2434297097' for the client 'totesrhelly.turbamentis.int'.\n179722:recover: Building the recovery list of the client 'totesrhelly.turbamentis.int'.\n179725:recover: Checking for the availability of the disk space on the client 'totesrhelly.turbamentis.int' for the recovery of the specified file(s).\nRecovering a subset of 11 files within \/ into \/tmp\/critrebuild\n179728:recover: Initializing the recovery session with the NetWorker server 'orilla' to recover the selected files.\nRecover start time: Sun 15 Aug 2021 12:24:31 AEST\n179718:recover: Initializing to recover multiple streams of data from the NetWorker server 'orilla'.\nRequesting 1 recover session(s) from server.\n179714:recover: Initializing the child threads to recover the given recovery stream from the NetWorker server 'orilla'.\n179713:recover: Initializing to set up a connection to start reading the data from the recover stream.\n.\/critrebuild\/run_env.txt\n.\/critrebuild\/rpm_query_a.txt\n.\/critrebuild\/fdisk_l.txt\n.\/critrebuild\/mount.txt\n.\/critrebuild\/mdstat.txt\n.\/critrebuild\/ifconfig_a.txt\n.\/critrebuild\/netstat_ar.txt\n.\/critrebuild\/lvm_fullreport.txt\n.\/critrebuild\/systemctl_list.txt\n.\/critrebuild\/\n179716:recover: Coordinating all the child recovery processes.\n179717:recover: Releasing all the resources held by the recovery process.\n179721:recover: All recovery streams from the NetWorker server 'orilla' are read successfully.\nReceived 10 matching file(s) from NSR server `orilla'\nUnneeded files and directory listings are discarded and excluded from the matching file count.\nRecover completion time: Sun 15 Aug 2021 12:24:33 AEST\n179068:recover: Step (9 of 10) for PID-8458: The recovery completed successfully on the client 'totesrhelly.turbamentis.int'.\n[root@totesrhelly \/]# <strong>ls \/tmp\/critrebuild\/<\/strong>\ncritrebuild\n[root@totesrhelly \/]# <strong>ls \/tmp\/critrebuild\/critrebuild\/<\/strong>\nfdisk_l.txt     lvm_fullreport.txt  mount.txt       rpm_query_a.txt  systemctl_list.txt\nifconfig_a.txt  mdstat.txt          netstat_ar.txt  run_env.txt<\/pre>\n\n\n\n<p>Sometimes you want specific savesets to stand out. They might be for database dumps (e.g., for a database with no module), KVM backups like the example at the start, or even just &#8216;essential&#8217; rebuild data. As always, the power of NetWorker is in its flexibility and adaptability to do what you need.<\/p>\n\n\n\n<p>Rolling your own savesets? You can definitely do that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you know that NetWorker lets you &#8216;roll your own&#8217; savesets? This functionality gives you a great deal of flexibility in customising your backup configuration to make critical datasets readily identifiable. Here&#8217;s how.<\/p>\n","protected":false},"author":1,"featured_media":9829,"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":[6,16],"tags":[1629,856],"class_list":["post-10572","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basics","category-networker","tag-customisation","tag-saveset"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/nsrd.info\/blog\/wp-content\/uploads\/2020\/12\/bigStock-Support-and-Tools.jpg","jetpack_shortlink":"https:\/\/wp.me\/pKpIN-2Kw","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/10572","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=10572"}],"version-history":[{"count":5,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/10572\/revisions"}],"predecessor-version":[{"id":10590,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/10572\/revisions\/10590"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/media\/9829"}],"wp:attachment":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/media?parent=10572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/categories?post=10572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/tags?post=10572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}