cancel
Showing results for 
Search instead for 
Did you mean: 

BPIMAGELIST - Output desired fields from image DB (Windows)

-matt-
Level 4

NBU 7.5.0.4
W2K8R2

Hi all,
I saw a great artical from Andy Welburn advising how best to use bpimagelist with awk to output the desiered fields from the image database on UNIX;

DOCUMENTATION: What are the different fields in "bpimagelist -l" output?
http://www.symantec.com/business/support/index?pag...

Elapsed time is one of the output fields....

Also, bpimagelist -L will give these fields in a more readable form.

You could be looking at a lot of output so may want to "filter" your results somehow!

e.g.

bpimagelist -l -d 06/07/2011 00:00:00 -e 06/08/2011 00:00:00 -client client | awk '/^IMAGE/ {print $2, $7, $15}'

will produce output only of client name, policy & elapsed time (seconds) for backups between those times.

I'm looking for the equivilent tool to manipulate the output on Windows and found the nearest option is FINDSTR, but it doesn't quite cut it.  It filters the output like grep but theres no controlling what fields from the image database to display.

I need to output client name, backup date, schedule, copy number, expiration date and byte count for a number of clients.  I find this simple task frustratingly difficult in the unlicensed (currently) version of Ops Centre.

Any help appreciated.

Matt

1 ACCEPTED SOLUTION

Accepted Solutions

Mark_Solutions
Level 6
Partner Accredited Certified

Good stuff - i did put my amended script above but having said that i think i altered it to use either -l or maybe even bpmedialist!

Keep us updated on the progress!

View solution in original post

14 REPLIES 14

Mark_Solutions
Level 6
Partner Accredited Certified

Two options here ..

One is to use a batch file (.bat) that first runs the command and outputs the result and then runs a vb script that reads this output and reads the appropriate fields - arrFields - and outputs just what you want

See if you can find someone good at that to assist

The second is to download grep for Windows - just google it - you can then use the same commands as in Andys excellent thread

Hope this helps

D_Flood
Level 6

Since you're running Win 2k8 R2 you could install the Services for Unix subsystem.  But just installing the role doesn't give you any tools.  You also have to download and install the SDK for Services for Unix and set your path correctly.  Then things like SED and AWK are there and have about 98% of the usual functionality (the syntax can be a little different).

 

Mark_Solutions
Level 6
Partner Accredited Certified

Ok - done a little work for you ...

Rename list.txt to list.bat and imagelist.txt to imagelist.vbs and put both in the root of the C drive on the Master

Edit list.bat so that the path for bpimagelist is correct

Run list.bat and it should produce imagelist.csv in the root of the C drive

Haven't tested it so it may need some work but give it a go

Hope this helps

StefanosM
Level 6
Partner    VIP    Accredited Certified
you can use msysgit. I tried almost all UNIX alternatives and I found that msysgit is probably the best. I'm installing it on every windows installation I have. http://code.google http://code.google.com/p/msysgit/downloads/liste

-matt-
Level 4

Hi all, 

Just checking posts whist back at home.

Thanks to everyone for your replies, espescially Mark_Solutions for actaully coding up a solution!

Will look at them all tomorrow.

Much appreciated, 

Matt

 

revarooo
Level 6
Employee

I did this by installing Cygwin, you get grep and awk. Perfect.

Nicolai
Moderator
Moderator
Partner    VIP   

Glad to hear.

Please consider to mark one of the post as a soloution.

Mark_Solutions
Level 6
Partner Accredited Certified

Due to the output of the command will need to do more work on this one .. will get back to you later

Mark_Solutions
Level 6
Partner Accredited Certified

Ok - needs lots of work!! - but sure you get the idea and maybe can play with it a bit.

Latest attempt uses the following for the first 3 fiedls needed - trouble is that dates and times are in unix

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\imagelist.txt", ForReading)


Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    arrFields = Split(strLine, " ")

    If InStr(arrFields(0), "IMAGE") Then
        strContents = strContents & arrFields(1) & "," & arrFields(6) & "," & arrFields(10) & "," & vbCrlf
    End If
Loop

objFile.Close

strContentsa = "Client Name,Policy,Schedule," & vbCrlf


Set objFile = objFSO.CreateTextFile("C:\imagelist.csv")
objFile.Write strContentsa

objFile.Write strContents


objFile.Close

.....................................

One thought here, it is not exactly what you need but not far off, have you tried this:

bpcatlist -since-days 7 -client clientname

or for everything just bpcatlist ( a few day /week / month options etc for this command too)

Is that near enough?

-matt-
Level 4

Spoiled for choice here, but I've had some help with the scripting.
Mark, I had errors running your script.  I think bpimagelist with the -L parameter produces the output in a nice list, but not sure if your code accounts for that and is expecting one long line of output?  Anyway, it bombed out.

I've got this slighted modified version which appears to do the trick;

Const ForReading = 1
Dim arrOutput(7)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\imagelist.txt", ForReading)
Set objOutput = objFSO.CreateTextFile("C:\imagelist.csv")
objOutput.WriteLine "Client Name,Policy,Schedule Label,Backup Date,Expiry Date,Backup Size(KB),Schedule Type,Copies"

Do Until objFile.AtEndOfStream
 boolEmpty = TRUE
    arrFields = Split(objFile.ReadLine, ": ")

 If UBound(arrFields) => 1 then
  If arrFields(0) = "Client" Then arrOutput(0) = Trim(arrFields(1))
  If arrFields(0) = "Policy" Then arrOutput(1) = Trim(arrFields(1))
  If arrFields(0) = "Sched Label" Then arrOutput(2) = Trim(arrFields(1))
  If arrFields(0) = "Backup Time" Then arrOutput(3) = Trim(Left(arrFields(1), Instr(arrFields(1), " (")))
  If arrFields(0) = "Expiration Time" Then arrOutput(4) = Trim(Left(arrFields(1), Instr(arrFields(1), " (")))
  If arrFields(0) = "Kilobytes" Then arrOutput(5) = Trim(arrFields(1))
  If arrFields(0) = "Schedule Type" Then arrOutput(6) = Trim(Left(arrFields(1), Instr(arrFields(1), " (")))
  If arrFields(0) = "Number of Copies" Then arrOutput(7) = Trim(arrFields(1))
 End If

 For Each strElemenent in arrOutput
  If strElemenent = vbEmpty Then
   boolEmpty = TRUE
   Exit For
  End If
  boolEmpty = FALSE
 Next

 If Not boolEmpty Then
  For intCount = LBound(arrOutput) To UBound(arrOutput)
   If intCount = UBound(arrOutput) Then
    strOutput = strOutput & arrOutput(intCount)
   Else
    strOutput = strOutput & arrOutput(intCount) & ","
   End If

   arrOutput(intCount) = vbEmpty
  Next

  objOutput.WriteLine strOutput
  strOutput = ""
 End If
Loop

objFile.Close
objOutput.Close

Work is still required but its coming along nicely thanks to you.

Mark_Solutions
Level 6
Partner Accredited Certified

Good stuff - i did put my amended script above but having said that i think i altered it to use either -l or maybe even bpmedialist!

Keep us updated on the progress!

-matt-
Level 4

Hi Mark et all,

Loads more progress with the script and I'm happy that this has formed a solution.  The lowercase -l allowed a better way delimit the the txt in the output file.  Just tweaking it a bit to get the desired output.


Points to Mark for his hard work on the script but a big thanks to all who contributed.

...I am a Windows man! :)

Vickie
Level 6

 

Please follow below steps,
 
1) First run below command.
 
C:\>bpimagelist -client client_name -hoursago 100 -l > imagelist.txt
 
2) Now run below command.
 
C:\>FOR /F "tokens=1,2,11,14,16,19" %G in (imagelist.txt) DO @echo %G    %H   %I    %J    %K    %L| findstr /B IMAGE
 
 
Out-put of the above 2nd mentioned command is as follows.
 
IMAGE    client_name Differential-Inc    1364180573    1365390173    614
IMAGE    client_name Differential-Inc    1364180410    1365390010    793
IMAGE    client_name Differential-Inc    1364094167    1365303767    465
IMAGE    client_name Differential-Inc    1364094005    1365303605    785
IMAGE    client_name Full    1364011372    1365220972    912626
IMAGE    client_name Full    1364011211    1365220811    54302
IMAGE    client_name Differential-Inc    1364007767    1365217367    10037
IMAGE    client_name Differential-Inc    1364007608    1365217208    1565
IMAGE    client_name Weekly-Full    1364004957    1372040157    1287292
IMAGE    client_name Weekly-Full    1364004636    1372039836    6598390
IMAGE    client_name Weekly-Full    1364004002    1372039202    8752255
IMAGE    client_name Differential-Inc    1363921360    1365130960    1464
IMAGE    client_name Differential-Inc    1363921205    1365130805    1573
IMAGE    client_name Daily-Incremental    1363910647    1365120247    1287151
IMAGE    client_name Daily-Incremental    1363910555    1365120155    492477
IMAGE    client_name Daily-Incremental    1363910402    1365120002    383047
 
Following are the fileds mentioned in above outcome
 
1) Record Header
2) Client Name
3) Schedule Label
4) Backup Time
5) Expiration
6) Kbytes Written
 
3) To get the time from 4th and 5th fields, you have to run below command. I used the 4th and 5th field from output given above.
 
C:\>bpdbm -ctime 1364180573
1364180573 = Sun Mar 24 23:02:53 2013
 
C:\>bpdbm -ctime 1365390173
1365390173 = Sun Apr 07 23:02:53 2013
 
This might give the desired information as you asked in your post. smiley
Please let us know if this is what you'r looking for.

 

Hi Matt,

I used your script to export the data but I cannot make it to work if you have additional Tape copies and the imagelist.txt has the attached format. As you can see there are Copy number : 2 and Copy number : 3 fields for the additional tape copies. The required export is to include except of your fields, additional fields like:

For Copy number : 2

ID : 

For Copy number : 3

ID : 

Could you please help on this?

 

Thx