{"id":1106,"date":"2009-10-01T17:46:38","date_gmt":"2009-10-01T07:46:38","guid":{"rendered":"http:\/\/nsrd.wordpress.com\/?p=1106"},"modified":"2009-10-01T17:46:38","modified_gmt":"2009-10-01T07:46:38","slug":"using-networker-for-live-search","status":"publish","type":"post","link":"https:\/\/nsrd.info\/blog\/2009\/10\/01\/using-networker-for-live-search\/","title":{"rendered":"Using NetWorker for Live Search"},"content":{"rendered":"<p>There was recently a discussion on the NetWorker mailing list regarding a situation whereby a company was skipping certain media files (e.g., *.mp3) from a fileserver, but still wanted to know when those files were present. In this case, the backup administrator didn&#8217;t have administrative rights to the fileserver, so doing a straight search of the fileserver wasn&#8217;t really an option.<\/p>\n<p>One proposed solution was to change the &#8220;skip&#8221; to &#8220;null&#8221;, which does cause <em>some<\/em> index information to be stored that can be searched with nsrinfo. How useful that &#8220;some&#8221; is though is of debate. The reason for this is that if you &#8220;null&#8221; a file in a backup, it will only be reported via an <em>nsrinfo -v<\/em> command, and it won&#8217;t be reported with the full path to the file, meaning it&#8217;s necessary to walk the <em>nsrinfo -v<\/em> output to scan each new change of path then construct the null&#8217;d file paths from there.<\/p>\n<p>As an exercise for the list, I tried this out &#8211; here&#8217;s what I reported at the time:<\/p>\n<p>Creating the test area we want to test with using the following commands &#8211;<\/p>\n<pre># mkdir \/testing\n# cp bigfile \/testing\n# cd \/testing\n# dd if=\/dev\/zero bs=1024k count=1024 of=test.dat<\/pre>\n<p>Following this, configure a \/testing\/.nsr directive with the following content:<\/p>\n<pre>&lt;&lt; . &gt;&gt;\nnull: test.dat<\/pre>\n<p>Now a backup can be run of the &#8220;\/testing&#8221; directory; because of the directive, &#8220;test.dat&#8221; will be excluded.<\/p>\n<p>Finding <em>test.dat<\/em> in nsrinfo output however is a little more tricky:<\/p>\n<pre>[root@nox testing]# nsrinfo -t `mminfo -q \"name=\/testing\" -r nsavetime` nox\nscanning client `nox' for savetime 1254265148(Wed 30 Sep 2009 08:59:08 AM EST)\nfrom the backup namespace\n\/testing\/.nsr\n\/testing\/bigfile\n\/testing\/\n\/\n4 objects found<\/pre>\n<p>There&#8217;s no test.dat listed there. Resorting to &#8216;-v&#8217; on nsrinfo, we do get the information, but as you can see, it&#8217;s more challenging to isolate the full path to the file:<\/p>\n<pre>[root@nox testing]# nsrinfo -t `mminfo -q \"name=\/testing\" -r nsavetime` -v nox\nscanning client `nox' for savetime 1254265148(Wed 30 Sep 2009 08:59:08 AM EST) from the\nbackup namespace\nUNIX ASDF v2 file `\/testing\/.nsr', NSR size=188, fid = 2304.586641, file size=23\nUNIX ASDF v2 file `\/testing\/bigfile', NSR size=196195024, fid = 2304.97665, file\n\u00a0size=196176812\nUNIX ASDF v2 file `\/testing\/', NSR size=244, fid = 2304.97664, file size=4096\n ndirentry-&gt;586641\u00a0\u00a0 \u00a0.nsr\n ndirentry-&gt;97669\u00a0\u00a0 \u00a0test.dat          &lt;----- Here it is ------&gt;\n ndirentry-&gt;2\u00a0\u00a0 \u00a0..\n ndirentry-&gt;97665\u00a0\u00a0 \u00a0bigfile\nUNIX ASDF v2 file `\/', NSR size=772, fid = 2304.2, file size=4096\n ndirentry-&gt;3677476\u00a0\u00a0 \u00a0.vmware\/\n ndirentry-&gt;846145\u00a0\u00a0 \u00a0mnt\/\n ndirentry-&gt;97633\u00a0\u00a0 \u00a0.autorelabel\n ndirentry-&gt;11\u00a0\u00a0 \u00a0lost+found\/\n ndirentry-&gt;2343169\u00a0\u00a0 \u00a0lib64\/\n ndirentry-&gt;2701153\u00a0\u00a0 \u00a0media\/\n ndirentry-&gt;1985185\u00a0\u00a0 \u00a0opt\/\n ndirentry-&gt;2668609\u00a0\u00a0 \u00a0etc\/\n ndirentry-&gt;1431937\u00a0\u00a0 \u00a0sbin\/\n ndirentry-&gt;4133089\u00a0\u00a0 \u00a0srv\/\n ndirentry-&gt;618337\u00a0\u00a0 \u00a0boot\/\n ndirentry-&gt;97638\u00a0\u00a0 \u00a0.bash_history\n ndirentry-&gt;1366849\u00a0\u00a0 \u00a0bin\/\n ndirentry-&gt;2766241\u00a0\u00a0 \u00a0selinux\/\n ndirentry-&gt;3417121\u00a0\u00a0 \u00a0tmp\/\n ndirentry-&gt;97644\u00a0\u00a0 \u00a0.autofsck\n ndirentry-&gt;585793\u00a0\u00a0 \u00a0root\/\n ndirentry-&gt;1692289\u00a0\u00a0 \u00a0lib\/\n ndirentry-&gt;97647\u00a0\u00a0 \u00a0nsr\n ndirentry-&gt;0\u00a0\u00a0 \u00a0sys\/\n ndirentry-&gt;97648\u00a0\u00a0 \u00a0home\n ndirentry-&gt;1887553\u00a0\u00a0 \u00a0usr\/\n ndirentry-&gt;2147905\u00a0\u00a0 \u00a0var\/\n ndirentry-&gt;2245537\u00a0\u00a0 \u00a0d\/\n ndirentry-&gt;0\u00a0\u00a0 \u00a0dev\/\n ndirentry-&gt;0\u00a0\u00a0 \u00a0net\/\n ndirentry-&gt;0\u00a0\u00a0 \u00a0misc\/\n ndirentry-&gt;0\u00a0\u00a0 \u00a0proc\/\n ndirentry-&gt;2\u00a0\u00a0 \u00a0..\n ndirentry-&gt;97664\u00a0\u00a0 \u00a0testing\/\n4 objects found<\/pre>\n<p>So while this solution works, I&#8217;m not convinced it&#8217;s ideal in all instances.<\/p>\n<p>The other solution I came up with I think works a little better, more reliably, and has the advantage of doing a live search on the filesystem <em>even if the backup administrator doesn&#8217;t have administrator privileges<\/em>.<\/p>\n<p>So, the other solution is to make use of the RUSER\/RCMD functionality in NetWorker to &#8220;have a chat&#8221; to the client daemons and get them to do something useful. Note that this is reasonably secure &#8211; you can only ask to run commands starting with &#8220;nsr&#8221; or &#8220;save&#8221;, and those commands <em>must<\/em> reside in the same directory as the <em>save<\/em> binary. In this case, we want to invoke <em>save<\/em>. All you have to do is turn off whatever directives are in place for the client, then setup a no-save command execution for the client.<\/p>\n<p>In the example below, we&#8217;re going to get the client &#8220;asgard&#8221; to do a no-save backup of its \/root folder, reporting back to the server &#8220;nox&#8221; but without actually transferring any data:<\/p>\n<pre>[root@nox testing]# RCMD=\"save -s nox -n \/root\"\n[root@nox testing]# RUSER=root\n[root@nox testing]# export RCMD RUSER\n[root@nox testing]# nsrexec -c asgard\nWarning: Could not determine job id: Connection timed out. Continuing ...\n\/root\/.elinks\/globhist\n\/root\/.elinks\/cookies\n\/root\/.elinks\/gotohist\n\/root\/.elinks\/\n\/root\/.bash_profile\n\/root\/.tcshrc\n\/root\/aralathan.pub\n\/root\/.my.cnf\n\/root\/anaconda-ks.cfg\n\/root\/nmsql521_win_x86.zip\n\/root\/nw_linux_x86.tar.gz\n&lt;snip&gt;\n32477:(pid 29247):\nsave: \/root 155 records 32 KB header 855 MB data\n\nsave: \/root 855 MB estimated<\/pre>\n<p>This style of command will work equally for Windows and Unix systems &#8211; indeed, I&#8217;ve done similar things on both Windows and Unix.<\/p>\n<p>Obviously, once you&#8217;re done gathering the file list, it&#8217;s important to then re-enable any directives turned off for the test\/file walk.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There was recently a discussion on the NetWorker mailing list regarding a situation whereby a company was skipping certain media&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,20],"tags":[659,784,848,852,872],"class_list":["post-1106","post","type-post","status-publish","format-standard","hentry","category-networker","category-scripting","tag-nsrexec","tag-rcmd","tag-ruser","tag-save","tag-search"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pKpIN-hQ","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/1106","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=1106"}],"version-history":[{"count":0,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"wp:attachment":[{"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nsrd.info\/blog\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}