Announcement

Collapse
No announcement yet.

RSM script sometimes not setting a variable

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • RSM script sometimes not setting a variable

    I recently wrote (er, put together) a script to get the GUID of the tape that is in the tape drive. It worked fine for a week then it failed..... then, without any interaction that I know of, it started working again.

    Lines of relevant code:
    Code:
    Set drvguid=8D856799624C44ADA6890EC652B15941 
    FOR /F "usebackq delims==" %%x IN (`rsm view /tphysical_media /cg%drvguid% /guiddisplay /b`) DO set tapeguid=%%x
    Output when working:
    Code:
    C:\WINDOWS\system32>Set drvguid=8D856799624C44ADA6890EC652B15941  
    
    C:\WINDOWS\system32>FOR /F "usebackq delims==" %x IN (`rsm view /tphysical_media /cg8D856799624C44ADA6890EC652B15941 /guiddisplay /b`) DO set tapeguid=%x 
    
    C:\WINDOWS\system32>set tapeguid=6382E4A892CE41ACBA4FC105D42A467F 
    
    C:\WINDOWS\system32> continues executing script without issue
    Output when not working:

    Code:
    C:\WINDOWS\system32>Set drvguid=8D856799624C44ADA6890EC652B15941  
    
    C:\WINDOWS\system32>FOR /F "usebackq delims==" %x IN (`rsm view /tphysical_media /cg8D856799624C44ADA6890EC652B15941 /guiddisplay /b`) DO set tapeguid=%x 
    
    C:\WINDOWS\system32> goes directly to next line without setting the "tapeguid" variable
    Does anyone know why this happens? Do I need to run a rsm refresh before executing the the rsm view? Any help would be great.


    Here's the full script:
    Code:
    Set drvguid=8D856799624C44ADA6890EC652B15941 
    FOR /F "usebackq delims==" %%x IN (`rsm view /tphysical_media /cg%drvguid% /guiddisplay /b`) DO set tapeguid=%%x
    FOR /F "usebackq delims==" %%x IN (`rsm view /tpartition /cg%tapeguid% /guiddisplay /b`) DO set partguid=%%x
    FOR /F "usebackq delims==" %%x IN (`rsm view /tlogical_media /cg%partguid% /guiddisplay /b`) DO set logguid=%%x
    Set part1=%logguid:~0,8%
    Set part2=%logguid:~8,4%
    Set part3=%logguid:~12,4%
    Set part4=%logguid:~16,4%
    Set part5=%logguid:~20,12%
    Set bkupguid=%part1%-%part2%-%part3%-%part4%-%part5%
    
    C:\WINDOWS\system32\ntbackup.exe backup "@C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\Daily Backup.bks" /n "Daily Backup %date%" /d "Daily Backup %date%" /v:yes /r:no /rs:no /hc:on /m normal /j "Daily Backup" /l:s /g "%bkupguid%"
    
    rsm eject /pg%tapeguid% /astart
    Regards,
    Jeremy

    Network Consultant/Engineer
    Baltimore - Washington area and beyond
    www.gma-cpa.com

  • #2
    Re: RSM script sometimes not setting a variable

    What about letting it wait until it get's a variable and then continue?
    GoogleFu is strong with this one ^

    Comment


    • #3
      Re: RSM script sometimes not setting a variable

      Originally posted by JeremyW View Post
      Do I need to run a rsm refresh before executing the the rsm view?
      I think that should help, if it's an intermittent problem though it will be hard to tell whether it makes any real difference.
      Gareth Howells

      BSc (Hons), MBCS, MCP, MCDST, ICCE

      Any advice is given in good faith and without warranty.

      Please give reputation points if somebody has helped you.

      "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

      "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

      Comment


      • #4
        Re: RSM script sometimes not setting a variable

        Originally posted by stamandster View Post
        What about letting it wait until it get's a variable and then continue?
        How would you go about waiting until it gets a variable?
        I did add code so that if the variable isn't defined it will add a short delay and then retry the command. It will do this upto 5 times.

        Originally posted by gforceindustries View Post
        I think that should help, if it's an intermittent problem though it will be hard to tell whether it makes any real difference.
        So what does the refresh command do exactly and what should I refresh?
        Regards,
        Jeremy

        Network Consultant/Engineer
        Baltimore - Washington area and beyond
        www.gma-cpa.com

        Comment


        • #5
          Re: RSM script sometimes not setting a variable

          Originally posted by JeremyW View Post
          So what does the refresh command do exactly and what should I refresh?
          rsm /refresh (I believe) forces RSM to update its list of media pools, most importantly making sure it has updated itself after you've changed tape. Usually it does this automatically, but if the server is under heavy load then that can cause a delay. Running the command causes an (almost) instant refresh.

          When you run it you have to specify which media pool you want it to refresh. So in our backup scripts, we have the line

          start /wait rsm.exe refresh /lf"TANDBERG TS800 SCSI Sequential Device"

          to force it to check which tape is in our LTO3 drive.

          (start /wait meaning that the command will be executed and the batch file will be halted until that command finishes).
          Gareth Howells

          BSc (Hons), MBCS, MCP, MCDST, ICCE

          Any advice is given in good faith and without warranty.

          Please give reputation points if somebody has helped you.

          "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

          "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

          Comment


          • #6
            Re: RSM script sometimes not setting a variable

            Thanks Gareth. We'll see what happens.
            Regards,
            Jeremy

            Network Consultant/Engineer
            Baltimore - Washington area and beyond
            www.gma-cpa.com

            Comment


            • #7
              Re: RSM script sometimes not setting a variable

              No worries. Good luck, let us know how you get on

              Tape drives are a bugger to work with at the command line until you get your head around what's going on. The documentation I found for both ntbackup and rsm was incredibly poor. Which reminds me, I was going to start a thread on here of everything I learned in my first 3 months in a proper job. They're very powerful and flexible tools, *if* you know how to coax the best out of them. And while you can achieve the same results with the GUI - where's the fun in that? Far better in my view to learn how to script such valuable tools - if you can automate your backups it saves you so much work.
              Gareth Howells

              BSc (Hons), MBCS, MCP, MCDST, ICCE

              Any advice is given in good faith and without warranty.

              Please give reputation points if somebody has helped you.

              "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

              "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

              Comment


              • #8
                Re: RSM script sometimes not setting a variable

                Just wanted to give an update. Things seems to be resolved but I still don't know what the issue is.

                The refresh had no effect on the results. What ended up working for me is having the script retry the command until it defined the variable. So far the script on had to retry once and it got it. Things have been running smoothly since.

                Thanks anyways for the input guys.

                If anyone's interested here's an example of the code I added to the script to make it retry.

                Code:
                SET n=0
                :VARSET
                set /a n=%n% + 1
                echo %n%
                
                
                set /P x=
                
                If defined x (goto continue) else (
                If NOT %n%==5 (ping 1.1.1.1 & goto VARSET)
                echo Could not get var
                pause
                exit
                )
                
                :CONTINUE
                Regards,
                Jeremy

                Network Consultant/Engineer
                Baltimore - Washington area and beyond
                www.gma-cpa.com

                Comment


                • #9
                  Re: RSM script sometimes not setting a variable

                  Thanks for posting back, good to know you at least got it working.
                  Gareth Howells

                  BSc (Hons), MBCS, MCP, MCDST, ICCE

                  Any advice is given in good faith and without warranty.

                  Please give reputation points if somebody has helped you.

                  "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

                  "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

                  Comment

                  Working...
                  X