Dears,
I made an attempt here to chart the RMAN backup foot (useful in capacity planning visualisation) print based on recovery window based retention window.
The python code is very simple, but it took few hours to bring out the logic (algorithm) to chart the data.
############################
# variable declaration , value assignment and validation begins here
j=0
k=0
# backup recovery window
print('please enter the backup recovery window')
a=input()
m=int(a)
# backup data display window
while True:
print('please enter the number of days to visualize the backup data')
b=input()
n=int(b)
if n>40:
print('please enter less than 40 days to visualize the backup data')
continue
else:
break
# level 0 backup frequency (number of days once)
print('please enter level0 backup frequency')
c=input()
o=int(c)
# variable declaration ends here
#display the header
dstr='|||||BTYP||'
for i in range(n-1,0,-1):
p=len(str(i))
j=5-p-2
dstr=dstr+' '*j+'D'+str(i)+'|'
k=len(dstr)
dstr2=dstr + ' LC | AC |'
v=len(dstr2)-k
print(dstr2)
#header display closes here
#backup data visualization
for i in range(1,n):
if i%o==1:
if i==1:
l='L0+A|'
t=l
else:
l='L0+A|' + l
t='L0+A|'
else:
if (i%o>=2) and (i>o):
if (m==o) and (i%m==2):
l=' A|'*(o-1) + 'L0+A|'
l=' A|' + 'L0+A|' + l
t=' A|'
elif (m<o) and (i%o==m+1):
l=' A|'*m + 'L0+A|'
t=' A|'
elif (m>o) and (i>m) and (i%o==(m-6)%o):
l=' A|'* (o-1) + 'L0+A|'
u=int(m/o)
l=' A|'* (m%o) + 'L0+A|' + l * u
t=' A|'
else:
l=' A|' + l
t=' A|'
else:
l=' A|' + l
t=' A|'
p=len(str(i))
j=5-p-2
q=' '*j + 'D' + str(i) + '|' + t
r=k-len(q)
s=q + ' '*(n-i-1)*5 + '|' + l
w=len(s)
d=l.count('L0')
e=len(str(d))
f=l.count('A')
g=len(str(f))
x=s + ' ' * (k-w) + ' ' * (5-e-1) + str(d) + '|' + ' ' * (5-g-1) + str(f) + '|'
print (x)
#backup data visualization closes here
############################
Please note I didnt add data points for L1, I will post that as an enhancement. So this code can help with L0 and Archives. Also may be next to next version, I will see if I can make the data displayed as an image of printed as csv, so we can increase the days and recovery window to see (larger foot print).
I made an attempt here to chart the RMAN backup foot (useful in capacity planning visualisation) print based on recovery window based retention window.
The python code is very simple, but it took few hours to bring out the logic (algorithm) to chart the data.
Objective:
In this blog, we will use python to plot RMAN backup foot print for n days (to my screen resolution I limited the max days to 40, but you can increase it if you wish by a simple code change) based on RMAN recovery window based retention.
Code:
############################
# variable declaration , value assignment and validation begins here
j=0
k=0
# backup recovery window
print('please enter the backup recovery window')
a=input()
m=int(a)
# backup data display window
while True:
print('please enter the number of days to visualize the backup data')
b=input()
n=int(b)
if n>40:
print('please enter less than 40 days to visualize the backup data')
continue
else:
break
# level 0 backup frequency (number of days once)
print('please enter level0 backup frequency')
c=input()
o=int(c)
# variable declaration ends here
#display the header
dstr='|||||BTYP||'
for i in range(n-1,0,-1):
p=len(str(i))
j=5-p-2
dstr=dstr+' '*j+'D'+str(i)+'|'
k=len(dstr)
dstr2=dstr + ' LC | AC |'
v=len(dstr2)-k
print(dstr2)
#header display closes here
#backup data visualization
for i in range(1,n):
if i%o==1:
if i==1:
l='L0+A|'
t=l
else:
l='L0+A|' + l
t='L0+A|'
else:
if (i%o>=2) and (i>o):
if (m==o) and (i%m==2):
l=' A|'*(o-1) + 'L0+A|'
l=' A|' + 'L0+A|' + l
t=' A|'
elif (m<o) and (i%o==m+1):
l=' A|'*m + 'L0+A|'
t=' A|'
elif (m>o) and (i>m) and (i%o==(m-6)%o):
l=' A|'* (o-1) + 'L0+A|'
u=int(m/o)
l=' A|'* (m%o) + 'L0+A|' + l * u
t=' A|'
else:
l=' A|' + l
t=' A|'
else:
l=' A|' + l
t=' A|'
p=len(str(i))
j=5-p-2
q=' '*j + 'D' + str(i) + '|' + t
r=k-len(q)
s=q + ' '*(n-i-1)*5 + '|' + l
w=len(s)
d=l.count('L0')
e=len(str(d))
f=l.count('A')
g=len(str(f))
x=s + ' ' * (k-w) + ' ' * (5-e-1) + str(d) + '|' + ' ' * (5-g-1) + str(f) + '|'
print (x)
#backup data visualization closes here
############################
Please note I didnt add data points for L1, I will post that as an enhancement. So this code can help with L0 and Archives. Also may be next to next version, I will see if I can make the data displayed as an image of printed as csv, so we can increase the days and recovery window to see (larger foot print).
Result:
please enter the backup recovery window
3
please enter the number of days to visualize the backup data
21
please enter level0 backup frequency
5
|||||BTYP|| D20| D19| D18| D17| D16| D15| D14| D13| D12| D11| D10| D9| D8| D7| D6| D5| D4| D3| D2| D1| LC | AC |
D1|L0+A| |L0+A| 1| 1|
D2| A| | A|L0+A| 1| 2|
D3| A| | A| A|L0+A| 1| 3|
D4| A| | A| A| A|L0+A| 1| 4|
D5| A| | A| A| A| A|L0+A| 1| 5|
D6|L0+A| |L0+A| A| A| A| A|L0+A| 2| 6|
D7| A| | A|L0+A| A| A| A| A|L0+A| 2| 7|
D8| A| | A| A|L0+A| A| A| A| A|L0+A| 2| 8|
D9| A| | A| A| A|L0+A| 1| 4|
D10| A| | A| A| A| A|L0+A| 1| 5|
D11|L0+A| |L0+A| A| A| A| A|L0+A| 2| 6|
D12| A| | A|L0+A| A| A| A| A|L0+A| 2| 7|
D13| A| | A| A|L0+A| A| A| A| A|L0+A| 2| 8|
D14| A| | A| A| A|L0+A| 1| 4|
D15| A| | A| A| A| A|L0+A| 1| 5|
D16|L0+A| |L0+A| A| A| A| A|L0+A| 2| 6|
D17| A| | A|L0+A| A| A| A| A|L0+A| 2| 7|
D18| A| | A| A|L0+A| A| A| A| A|L0+A| 2| 8|
D19| A| | A| A| A|L0+A| 1| 4|
D20| A|| A| A| A| A|L0+A| 1| 5|
>>>
In the above example, I used 3 days of recovery window, 5 days once L0 occurrence and 21 days of data to visualise my foot print.
Below are the list of charts that everyone looks forward :)
Recovery window: 8 days
Backup data to display: 21 days
L0 backup occurencce: 7 days once
please enter the backup recovery window : 15
please enter the number of days to visualize the backup data: 30
please enter level0 backup frequency : 7
Thanks for your visit. Please provide your valuable feedbacks.