cancel
Showing results for 
Search instead for 
Did you mean: 

Scripted File System Restore - NBU 7.6 (Windows/Linux)

RiyasHussain
Level 4

Hi All,

Do we have any script available for file system restore using NBU 7.6 Windows/Linux?

Customer is looking for script which include command line and performs pre check before restore?

bprestore command can preform the activity as mentioned in the document. But enhanced script is what customer is looking for.

Please provide inputs.

Thanks and Regards

Riyas Hussain A

1 ACCEPTED SOLUTION

Accepted Solutions

mph999
Level 6
Employee Accredited

 

This is a start ...

I created it for a one-off task, so it needs a loop to work out if it's a redirected restore or not, that way you don't have to uncomment anything:

#!/usr/bin/ksh
# **  WARNING - please check this script, run only if you are happy that it will not cause any adverse effect to your system
#Useage - restore.sh <filelist> <startdate>

#Filelist - list of files to restore
#Startdate - earliest date of backedup files
#Renamefile - File containg altpath eg.  change /netbackup/testdata to /tmp/res<CR>  (<CR> - Carriage return)

#Define variables

RENAMEFILE=/tmp/res/mph
LOGFILE=/tmp/res/restore_log.txt
FILELIST=/tmp/res/filelist
MASTER=womble  #master server
SOURCE=womble  #source machine for original backup
DESTINATION=womble  #destination/ target machine for restored files
STARTDATE=$1 #Startdate of earlist files to restore format mm/dd/yyyy

#Uncomment the line below if there is a restore file (restoring to an alt location)
#bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -R $RENAMEFILE -f $FILELIST

#Uncomment the line below if you are restoring to the same location
#bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -f $FILELIST


If you replace the last x4 lines with this:

if [ -f "$RENAMEFILE" ]
 then
  bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -R $RENAMEFILE -f $FILELIST
 else
  bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -f $FILELIST
fi

It should then work out if it is a redirected restore or not (depends if $RENAMEFILE exists) and run the correct command.
I've not tested this bit, but it should work.

Note, this is written for ksh - shell path may be different depending on OS, so the first line may need to be modified.


No idea if this will run in bash, not tried it.


It won't work on Windows, but someone with Windows scripting skills would be able to create something similar.

Not sure what checks you want before hand, but these should be failrly easy to add, perhaps a little project for you to modify the above.

View solution in original post

1 REPLY 1

mph999
Level 6
Employee Accredited

 

This is a start ...

I created it for a one-off task, so it needs a loop to work out if it's a redirected restore or not, that way you don't have to uncomment anything:

#!/usr/bin/ksh
# **  WARNING - please check this script, run only if you are happy that it will not cause any adverse effect to your system
#Useage - restore.sh <filelist> <startdate>

#Filelist - list of files to restore
#Startdate - earliest date of backedup files
#Renamefile - File containg altpath eg.  change /netbackup/testdata to /tmp/res<CR>  (<CR> - Carriage return)

#Define variables

RENAMEFILE=/tmp/res/mph
LOGFILE=/tmp/res/restore_log.txt
FILELIST=/tmp/res/filelist
MASTER=womble  #master server
SOURCE=womble  #source machine for original backup
DESTINATION=womble  #destination/ target machine for restored files
STARTDATE=$1 #Startdate of earlist files to restore format mm/dd/yyyy

#Uncomment the line below if there is a restore file (restoring to an alt location)
#bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -R $RENAMEFILE -f $FILELIST

#Uncomment the line below if you are restoring to the same location
#bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -f $FILELIST


If you replace the last x4 lines with this:

if [ -f "$RENAMEFILE" ]
 then
  bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -R $RENAMEFILE -f $FILELIST
 else
  bprestore -s $STARTDATE -S $MASTER -C $SOURCE -D $DESTINATION -L $LOGFILE  -f $FILELIST
fi

It should then work out if it is a redirected restore or not (depends if $RENAMEFILE exists) and run the correct command.
I've not tested this bit, but it should work.

Note, this is written for ksh - shell path may be different depending on OS, so the first line may need to be modified.


No idea if this will run in bash, not tried it.


It won't work on Windows, but someone with Windows scripting skills would be able to create something similar.

Not sure what checks you want before hand, but these should be failrly easy to add, perhaps a little project for you to modify the above.