cancel
Showing results for 
Search instead for 
Did you mean: 

Reading back<DBSID>.log

Richard_Bailey
Explorer
0 Kudos

Hello Gurus,

I want to write a script to read back<DBSID>.log and only return to me the lines that have the status of "on disk".

At this moment we do a 2 phase backup, first we backup to disk in sapbackup, then we move that backup to tape. However the sapbackup directory only has enough space to hold two complete backups, therefore I am trying to automatically delete the older backup before the new one starts every night.

Ideally I would like to get the output just as provided by brtools, i.e. like this:

BRBACKUP disk backups for backup

Pos.  Log           Start                Type              Files  Status   Rc

  1 = begvbmrt.and  2011-09-20 23.00.05  online          175/176  on disk   0
  2 - beguwowo.and  2011-09-19 23.00.02  online          175/176  on disk   0
  3 - begumtiq.afd  2011-09-17 23.01.00  offl_force      145/176  deleted   5
  4 - begptvzz.and  2011-08-23 23.00.15  online          175/176  deleted   5

Is there a way I can run brtools or a br* command to provide this output?

If I can get this I can then manipulate the output to get the older Log entry that is "on disk" and run the brbackup command to delete backup.

- Regards,

Richard

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I want to write a script to read back<DBSID>.log and only return to me the lines that have the status of "on disk".

You can also use "grep" tool to collect required information from arch<SID>.log.

# cat arch<SID>.log | grep "on disk"

It will return the lines which contain keyword "on disk".

Ideally I would like to get the output just as provided by brtools, i.e. like this:

If you want to store output in text file, just redirect it to text.file. You will need to add the header information at the top of the output file.

# 'cat arch<SID>.log | grep "on disk"' > back_on_disk.txt

(Please note the single quote (') before "cat" and after disk" )

Regards.

Rajesh Narkhede

Edited by: Rajesh Narkhede on Sep 22, 2011 12:12 PM

volker_borowski2
Active Contributor
0 Kudos

Hi,

For scripting you would start using

awk '/on disk/ ' backSID.log

To print only selected fields

awk '/on disk/ { print $5 " " $9 " " $4 }' backSID.log

Prints fields 5 9 and 4 with space in between, but only if the line contains the pattern "on disk"

Volker

Richard_Bailey
Explorer
0 Kudos

Thanks for that Volker,

That will help when I get the output I need.

Any tips on how to get usable information out of back<DBSID>.log?

- Regards,

Richard

volker_borowski2
Active Contributor
0 Kudos

Ya, sorry I've seen that too late and adjusted my posting while you typed your answer ...

Sorry

I am at home now and have no sample backSID.log

Can you post 3 or 4 lines using code-Tags, then I can give your a fitting awk that will do the job

Volker

volker_borowski2
Active Contributor
0 Kudos

Hi once more ...

since I have no sample data now, you might need to adjust the field numbers.

I think in backSID.log are two fields, one for the backup name and one for the extension.

I assume those two to be $3 and $4 for now. You might need to check and adjust !

awk '/on disk/ print { "brbackup -db " $3 "." $4 }' archSID.log

play around with this one, add options as you need, i.E.

awk '/on disk/ print { "brbackup -c -u / -db " $3 "." $4 }' archSID.log

You should get a command line for each hit of "on disk"

You can then use

awk '/on disk/ print { "brbackup -c -u / -db " $3 "." $4 }' archSID.log | head -1

to select only the first line of the output ( this will be the oldest backup )

When you are certain that all this generates the command as you like to have it,

you can pipe the result to a csh to be executed.

That would be simply

..... | csh

WARNING ! Do not execute twice, as the first call will modify backSID.log after successfull delete, so the

second call will delete (in this case the only remaining) last backup.

Volker

volker_borowski2
Active Contributor
0 Kudos

Hello,

I checked today: in a backSID.log written by brbackup 7.20 PL 16 the fields are the very first, so you should use $1 and $2.

Volker

@Rajesh: any reason why you use "cat"? grep is also capeable of taking an inputfilename!

Former Member
0 Kudos

Dear Volkar,

Please don't mind... I just suggested another way...

I thought using "cat" would be easy way, if some one is not familiar or comfortable with scripting...

I agree, "awk" is more perfect in pure scripting...

Regards.

Rajesh Narkhede