Forum Discussion

DPeaco's avatar
DPeaco
Moderator
2 months ago

Automating a NBU Restore with bprestore

Greetings,
NetBackup 10.3.0.1 Master and Media servers
Entire environment is Linux - RHEL 9

I'm looking for a way to automate a NetBackup restore in a script. I do speak "BASH". :-) 

I would like to take the server name, start and end date range and the path/filename from a menu and then do all the crunch work behind the scenes for data recovery. Some of the data will be on disk in the MSDP pool while others will be older data to be restored from tape.
Backup policy is a Standard policy backing up 2 specific locations on a Linux server.

Has anyone done this already? Tips and Pointers welcomed. :-)

  • Hello

    Are you aware of this command /usr/openv/netbackup/bin/bp ?? :)

     

  • Sounds like you're building some sort of operations menu?  What's your starting point?  "...from a menu"? 

    Are you looking to populate this menu from the NB database itself?  ...as some pseudocode "select <client> from <bpplclients>"

    Of course, most of what you're describing is already within the GUI.

    ?? -M

    • DPeaco's avatar
      DPeaco
      Moderator

      Hello Mark_Donaldson 
      I plan on querying a backup admin for date range, backup client host name, directory path and file name, last but not least, ask for where the file is to be restored to if different than the original file location, and then have the process run.

      I know I can use bpimagelist against a backup_id, grep for FRAG and feed that output to awk to print field position 9 and I can determine if the file is still on MSDP storage pool or if it's on tape. The eventual plan is, if it's on tape, check the tape library to see if the tape is in the library or not. If not, then build a list of required tape media, email that to the backup admin for recalling from offsite storage.

      • I guess I don't see why you can't just use the backup/restore GUI. It does all this, including the redirect, and restores are not a privileged function.  If you can normally read the file & write to the target with whatever user you're logged in as, you can perform a restore.

        You can mine bpimagelist for what you're saying but bpimmedia might be easier.  

        Is the tape/msdp thing because you have to manually load or recall a tape?

    • DPeaco's avatar
      DPeaco
      Moderator

      Mark_Donaldson 

      Yes...I know WE can do this in the GUI. But I'm trying to script it where my "user" can run a script, answer a few questions and the automated process does the rest. We do NOT allow end-users to have access to the GUI/admin console.

      • Mark_Donaldson's avatar
        Mark_Donaldson
        Level 3

        As mentioned above, there is the "bp" tool that's on every client and on windows there's, of course, the java client that's not part of the master console.

        all that said, if we're talking scripting, then in ksh you're looking for the "select" command.

        I'd do something like this:

        echo "Enter a partial client name for search:\c"
        read c
        select client from `bpplclients | grep -i $c`
        do
           echo "Client is $client"
          break
        done

        It's not very hardy this way.  It doesn't account for if no client is found.  It also doesn't handle ESX right since clients backed up with VMware policies don't show up in bpplclient output.  You'd have to mine bpimagelist for the client names, write them to a file then you could grep out the pattern from there.

        bpimagelist -hoursago 600 | awk '$=="IMAGE" {print $2}' | sort -u >/tmp/clientlist
        echo "Enter a partial client name to search:\c"
        read c
        k=`grep -ic $c /tmp/clientlist`
        if [ $k -eq 0]
        then
          echo "No client found"
        elif [ $k -gt 50 ]
          echo "Too many returns, please narrow your search."
        else
          #between 1 and 50 clients found
          select client from `grep -i $c /tmp/clientlist
          do
              echo "Chose $client"
              break
          done
        fi

        So - you can select a client this way.  Just kinda rinse & repeat for all the params you need to gather.

        -M