Running restores via the command line within NetBackup enables restore templates to be kept and if a large number of restores have to be run then a lot of repetition can be avoided which would not be possible via the GUI.
When restoring via the command line the files to be restored have to be confirmed then the actual restore process has to be run. This means that with two commands it is possible to complete the restore.
To get a long list of the files and their modification for a client backup use the bplist command. The following example will give a long listing of files backed up from the path /backup171 between the 19th and 21st June 2019. The command will search for files backed up with a standard type policy, -t 0, and it will list the files and all subdirectories recursively with the -R option
bplist -C <client_name> -R -l -t 0 -s 06/19/2019 -e 06/21/2019 /backup171
To list the files recursively from the / directory on a UNIX machine change the path to search to /
bplist -C <client_name> -R -l -b -t 13 -s 09/15/2019 /
To get the time that files were backed up use the -b option. The following list will search for windows type backups, specified by -t 13 – which denotes the windows policy type of 13. The recursive search will be from the the path /D/data/path
bplist -C <client_name> -R -l -b -t 13 -s 09/15/2019 /D/data/path
If a number of files are to be restored then the filenames should be captured into a file and that file then passed to the bprestore comand. The file can only contain the path and filename for each file hence the -l option to the bplist command is not required. The bprestore command can only work with a single path per filename per line.
When the files to restore have been decided upon, capture the output of the bplist command into a file by redirecting the output of the bplist command. The following command will list files backed up between 10 AM and 3 PM on the 5th January 2019 and redirect them to the file /tmp/restore.files
bplist -C CLIENT1 -R -s 01/05/2019 10:00:00 -e 01/05/2019 15:00:00 /path/of/files/to/restore > /tmp/restore.files
The bprestore command is very similar to the bplist command in terms of the options given. Options can be given to restore the files to an alternative location or to a different client
To restore the /etc/hosts file back to the original client it was backed up from and the original location, form a backup taken on the 1st July 2019, the command would be
bprestore -C LINUX-HOST -D LINUX-HOST -t 0 -s 07/01/2019 -L /usr/openv/netbackup/logs/user_ops/<userid>/restore.log /etc/hosts
It is also possible to specify an alternative location for the restore by using a change file which contains both the original backup path and the path in which the files should be restore. Each path which needs changed should be entered on a separate line in the file. The path to the change file is given to the bprestore command with the -R option.
The following example shows that two backup paths are being changed. During the restore process the restore progress log will show each file being restored into the new location
change /backup_directory_1 to /restore/path/directory1
change /backup_directory_2 to /restore/path/directory2
The bprestore command can also use the -D option to tell NetBackup the name of the alternate restore client. The output of the restore command will also be captured into a logfile via the -L option
The following bprestore command will restore the files listed in /tmp/restore.files, which were backed up from CLIENT1 between 10 AM and 3 PM on the 5th January 2019, to the paths specified in the changefile on the host CLIENT2
# bprestore -C CLIENT1 -D CLIENT2 --s 01/05/2019 10:00:00 -e 01/05/2019 15:00:00 -R /path/to/changefile -L /tmp/restore.logfile -f /tmp/restore.files
Restoring the J drive back to the same wintel client with the current date and time being incoporated into the logfile name
bprestore -C WINCLIENT1 -D WINCLIENT1 -s 02/21/2018 00:00:00 -e 02/21/2018 01:00:00 -t 13 -L /tmp/restore-`date +%a-%d-%b-%H:%M`.log /J
To restore the file exclude_list from a specific date to an alternative unix client and to an alternative path with a change file:
bprestore -C UNIXCLIENT1 -D UNIXCLIENT2 -s 09/21/2019 -t 0 -L /tmp/restore.log -R /tmp/change.file /usr/openv/netbackup/exclude_list