cancel
Showing results for 
Search instead for 
Did you mean: 

Need to find jobid triggered by bpduplicate command

Sid1987
Level 6
Certified

Hi Specialists,

 I need to build a script for manually duplicating backupid's from tapes to disk based storage unit. Now My plan is to find out backupid's through bpimmedia for set of media's and use bpduplicate to duplicate those backupid's to a storage unit. Now next step would be to check if the duplication job triggered by the bpduplicate complete or not, If it completed I need to expire those media's so they become scratch and I have the duplicated image promoted to as primary image. I was thinking of how to find out the jobid triggered by bpduplicate command in order to track what happened to it.

Thanks

Sid

1 ACCEPTED SOLUTION

Accepted Solutions

sdo
Moderator
Moderator
Partner    VIP    Certified

Hi Sid,

This little test worked for me (except that I didn't have a tape drive spun up - so ignore the 2001 error...).  FYI - the activity job ID of the duplication job is written to the file specified by the -L switch.  The script reads a list of media IDs and then finds all the images on each media, and appends each image name to a "BID" file, which is the main input into bpduplicate (i.e. a list of images to duplicate)...

 

...here's an example run...

>duplicate.bat
22/02/2014  1:10:59  Looking for images on media `400001`...
22/02/2014  1:10:59  ...found image `hserver_1393024017`...
22/02/2014  1:10:59  ...found image `hserver_1393023871`...
22/02/2014  1:11:01  Call to bpduplicate failed, status `2001`...
22/02/2014  1:11:01
22/02/2014  1:11:01  Checking for job id...
22/02/2014  1:11:01  Activity job is `2389`...

 

...my test input file (duplicate.med) was a list of media (in my test, just one media ID)...

>type duplicate.med
400001

 

...and here's the example script - you'll have to convert to ksh or perl or whatever...

>type duplicate.bat
@echo off
setlocal enabledelayedexpansion

set z_path=%~dp0
set z_name=%~n0

set z_file_bid=!z_path!!z_name!.bid
set z_file_dup=!z_path!!z_name!.dup
set z_file_ima=!z_path!!z_name!.ima
set z_file_log=!z_path!!z_name!.log
set z_file_med=!z_path!!z_name!.med

if exist "!z_file_bid!"  del "!z_file_bid!"
if exist "!z_file_dup!"  del "!z_file_dup!"
if exist "!z_file_ima!"  del "!z_file_ima!"
if exist "!z_file_log!"  del "!z_file_log!"


set z_date_dd_mm_yyyy=!date!
set z_date_dd=!z_date_dd_mm_yyyy:~0,2!
set z_date_mm=!z_date_dd_mm_yyyy:~3,2!
set z_date_yyyy=!z_date_dd_mm_yyyy:~6,4!

set z_date_beg=01/01/1970 00:00:00
set z_date_end=!z_date_dd!/!z_date_mm!/!z_date_yyyy! 23:59:59


for /f "tokens=1" %%a in ('type "!z_file_med!"') do (
  set z_media=%%a
  call :log "Looking for images on media `!z_media!`..."
  bpimmedia -l -mediaid !z_media! -d !z_date_beg! -e !z_date_end! >"!z_file_ima!"
  set z_sts=!errorlevel!
  if not !z_sts!==0 (
    call :log "Failed to list any images for media `!z_media!`, status `!z_sts!`..."
  ) else (
    for /f "tokens=1,2,3,4" %%a in ('type "!z_file_ima!"') do (
      set z_type=%%a
      set z_image=%%d

      if "!z_type!"=="IMAGE" (
        call :log "...found image `!z_image!`..."
        (echo !z_image!)>>"!z_file_bid!"
      )
    )
  )
)

REM ...this argument not required, as the target STU is a disk...
REM    -dp NetBackup
bpduplicate -number_copies 1 -dstunit hserver-dsu -v -L "!z_file_dup!" -Bidfile "!z_file_bid!"

set z_sts=!errorlevel!

if not !z_sts!==0 (
  call :log "Call to bpduplicate failed, status `!z_sts!`..."
)


call :log ""
call :log "Checking for job id..."

set z_jobid=unknown
for /f "tokens=1,2,3,4,5,6,7" %%a in ('type "!z_file_dup!"') do (
  if /i "%%b %%c %%d %%e"=="Activity monitor job id" (
    set z_jobid=%%g
  )
)
call :log "Activity job is `!z_jobid!`..."


:end
echo+
pause
exit /b


:log
(echo !date! !time:~0,8!  %~1)
(echo !date! !time:~0,8!  %~1)>>"!z_file_log!"
goto :eof

 

...and from my test the bpduplicate log file (in my case named "duplicate.dup"), was...

>type duplicate.dup
01:10:59 Duplicate started 22/02/2014 01:10:59
01:10:59 Activity monitor job id = 2389
01:11:01 INF - Cannot obtain resources for this job : error [2001]

 

(...ignore the 2001 error - that's because I didn't have a tape drive running...)

The script does not change retention, nor primary copy of the new copies.  It has my test disk storage unit target (hserver-dsu) but you can change that to the name of your target storage unit.  It's probably best to read about bpimmedia and bpduplicate in the commands reference manual to see if there are any other switches that are applicable to your particular situation.

Also note how the bpimmedia starts searching from the dawn of the universe (01/01/1970 00:00:00) - so if you have a big catalog stretching back for many years, yet you know the earliest data of any images on the list of media that you want to duplicate, then do change the start time, as this will speed things up greatly in a large catalog environment.

 

HTH,

Dave.

View solution in original post

5 REPLIES 5

Nicolai
Moderator
Moderator
Partner    VIP   

I belive you can do all that using  Netbackup Storage Lifecycle Policies (SLP). 

http://www.symantec.com/docs/HOWTO73205

Sid1987
Level 6
Certified

Thanks Nicolai for the reply.

I am already using SLP and these are backupid's which have completed their lifecycle, now I need to delete these tapes so I need to migrate the data, are you suggesting to create another SLP to migrate these media's? If yes How?

Marianne
Level 6
Partner    VIP    Accredited Certified

... how to find out the jobid triggered by bpduplicate command ....

Two possibilities (I don't have access to a NBU server to test/check):

1. Use -L option to create log/output file.

2. Create admin log folder on the server where you are running bpduplicate command.

Nicolai
Moderator
Moderator
Partner    VIP   

You can't re-SLP already compleated SLP jobs (wold be nice howver).

You can check if bpduplicate exited sucessfull by inspecting $? after bpduplicate command was run. Save $? to a variable right away to avoid it set to somthing else.

bpduplicate {bla bla bla}
RC=$?

If RC=0 everyting is OK else RC will be the Netbackup status code.

When you need to expire the data check if the new primary copy (-npc is bpduplicate is required) is two. If primary copy is 1 duplication had a error.

sdo
Moderator
Moderator
Partner    VIP    Certified

Hi Sid,

This little test worked for me (except that I didn't have a tape drive spun up - so ignore the 2001 error...).  FYI - the activity job ID of the duplication job is written to the file specified by the -L switch.  The script reads a list of media IDs and then finds all the images on each media, and appends each image name to a "BID" file, which is the main input into bpduplicate (i.e. a list of images to duplicate)...

 

...here's an example run...

>duplicate.bat
22/02/2014  1:10:59  Looking for images on media `400001`...
22/02/2014  1:10:59  ...found image `hserver_1393024017`...
22/02/2014  1:10:59  ...found image `hserver_1393023871`...
22/02/2014  1:11:01  Call to bpduplicate failed, status `2001`...
22/02/2014  1:11:01
22/02/2014  1:11:01  Checking for job id...
22/02/2014  1:11:01  Activity job is `2389`...

 

...my test input file (duplicate.med) was a list of media (in my test, just one media ID)...

>type duplicate.med
400001

 

...and here's the example script - you'll have to convert to ksh or perl or whatever...

>type duplicate.bat
@echo off
setlocal enabledelayedexpansion

set z_path=%~dp0
set z_name=%~n0

set z_file_bid=!z_path!!z_name!.bid
set z_file_dup=!z_path!!z_name!.dup
set z_file_ima=!z_path!!z_name!.ima
set z_file_log=!z_path!!z_name!.log
set z_file_med=!z_path!!z_name!.med

if exist "!z_file_bid!"  del "!z_file_bid!"
if exist "!z_file_dup!"  del "!z_file_dup!"
if exist "!z_file_ima!"  del "!z_file_ima!"
if exist "!z_file_log!"  del "!z_file_log!"


set z_date_dd_mm_yyyy=!date!
set z_date_dd=!z_date_dd_mm_yyyy:~0,2!
set z_date_mm=!z_date_dd_mm_yyyy:~3,2!
set z_date_yyyy=!z_date_dd_mm_yyyy:~6,4!

set z_date_beg=01/01/1970 00:00:00
set z_date_end=!z_date_dd!/!z_date_mm!/!z_date_yyyy! 23:59:59


for /f "tokens=1" %%a in ('type "!z_file_med!"') do (
  set z_media=%%a
  call :log "Looking for images on media `!z_media!`..."
  bpimmedia -l -mediaid !z_media! -d !z_date_beg! -e !z_date_end! >"!z_file_ima!"
  set z_sts=!errorlevel!
  if not !z_sts!==0 (
    call :log "Failed to list any images for media `!z_media!`, status `!z_sts!`..."
  ) else (
    for /f "tokens=1,2,3,4" %%a in ('type "!z_file_ima!"') do (
      set z_type=%%a
      set z_image=%%d

      if "!z_type!"=="IMAGE" (
        call :log "...found image `!z_image!`..."
        (echo !z_image!)>>"!z_file_bid!"
      )
    )
  )
)

REM ...this argument not required, as the target STU is a disk...
REM    -dp NetBackup
bpduplicate -number_copies 1 -dstunit hserver-dsu -v -L "!z_file_dup!" -Bidfile "!z_file_bid!"

set z_sts=!errorlevel!

if not !z_sts!==0 (
  call :log "Call to bpduplicate failed, status `!z_sts!`..."
)


call :log ""
call :log "Checking for job id..."

set z_jobid=unknown
for /f "tokens=1,2,3,4,5,6,7" %%a in ('type "!z_file_dup!"') do (
  if /i "%%b %%c %%d %%e"=="Activity monitor job id" (
    set z_jobid=%%g
  )
)
call :log "Activity job is `!z_jobid!`..."


:end
echo+
pause
exit /b


:log
(echo !date! !time:~0,8!  %~1)
(echo !date! !time:~0,8!  %~1)>>"!z_file_log!"
goto :eof

 

...and from my test the bpduplicate log file (in my case named "duplicate.dup"), was...

>type duplicate.dup
01:10:59 Duplicate started 22/02/2014 01:10:59
01:10:59 Activity monitor job id = 2389
01:11:01 INF - Cannot obtain resources for this job : error [2001]

 

(...ignore the 2001 error - that's because I didn't have a tape drive running...)

The script does not change retention, nor primary copy of the new copies.  It has my test disk storage unit target (hserver-dsu) but you can change that to the name of your target storage unit.  It's probably best to read about bpimmedia and bpduplicate in the commands reference manual to see if there are any other switches that are applicable to your particular situation.

Also note how the bpimmedia starts searching from the dawn of the universe (01/01/1970 00:00:00) - so if you have a big catalog stretching back for many years, yet you know the earliest data of any images on the list of media that you want to duplicate, then do change the start time, as this will speed things up greatly in a large catalog environment.

 

HTH,

Dave.