on 09-21-2011 6:15 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.