03-19-2013 09:50 AM
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
Solved! Go to Solution.
03-20-2013 09:37 AM
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!
03-19-2013 09:58 AM
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
03-19-2013 10:18 AM
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).
03-19-2013 10:28 AM
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
03-19-2013 11:01 AM
03-19-2013 02:07 PM
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
03-19-2013 02:49 PM
I did this by installing Cygwin, you get grep and awk. Perfect.
03-19-2013 10:38 PM
Glad to hear.
Please consider to mark one of the post as a soloution.
03-20-2013 03:01 AM
Due to the output of the command will need to do more work on this one .. will get back to you later
03-20-2013 03:31 AM
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?
03-20-2013 09:22 AM
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.
03-20-2013 09:37 AM
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!
03-25-2013 09:17 AM
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! :)
03-25-2013 09:32 AM
C:\>bpimagelist -client client_name -hoursago 100 -l > imagelist.txt
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
C:\>bpdbm -ctime 13641805731364180573 = Sun Mar 24 23:02:53 2013C:\>bpdbm -ctime 13653901731365390173 = Sun Apr 07 23:02:53 2013
03-09-2018 09:45 AM
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