How to restore files from the command line using the bprestore command

Article: 100003536
Last Published: 2019-06-08
Ratings: 1 2
Product(s): NetBackup & Alta Data Protection

Problem

Restoring files from the command line when the GUI/ Admin console is unavailable using the bprestore command.

Solution

The following is an example of how to run a restore from the command line :

1.  Create the directory /tmp/res
2.  Create a file called /tmp/res/filelist containing the files you wish to recover, for example :

/netbackup/testdata/file1
/netbackup/testdata/file2
/netbackup/testdata/file3
/netbackup/testdata/file4
/netbackup/testdata/file5

Note 1: If you have a filename that contains a space, you have to define the line like this.

<number of characters> <path/file>

For example, '/netbackup/testdata/my file' contains 27 characters, so the line would be:   27 /netbackup/testdata/my file

If your filename(s) do not contain spaces, then you can ignore this step.

Note 2: If you wish to restore to an alternative location, create a file called /tmp/res/alt_locate to specifiy the destination path.
Add a line like the following:

For this example the original location is /netbackup/testdata, but you wish to redirect to the new location /tmp/res:

change /netbackup/testdata to /tmp/res

If you are restoring to the original location, you can skip this step.

Sample script: This sample could be used to facilitate the restore. The script uses the example files suggested, /tmp/res/filelist and /tmp/res/alt_locate.

The variables MASTER, SOURCE and DESTINATION require changing to meet the environmental requirements.
There are two bprestore lines,  uncomment the one you wish to use, depending on if you create a alt_locate file.

Save this as /tmp/res/restore.sh
 

#!/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
#Usage - restore.sh <startdate>
#Filelist - list of files to restore
#Startdate - earliest date of backup image
#Renamefile - File containg altpath eg.  change /netbackup/testdata to /tmp/res<CR>  (<CR> - Carriage return)
#Define variables

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

#Uncomment the line below if there is a restore file (restoring to an alterntaive 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
#End of script

To run the script

./restore.sh <earliest date to restore files from> (substitute the date of the backup)

For example:

./restore.sh 10/23/2010   (See the manual page for bprestore (-s option) to check the format of the date on your system)

 

Applies To

Solaris 10
Netbackup 7.x

Was this content helpful?