-
Notifications
You must be signed in to change notification settings - Fork 0
/
oci-check-backups.sh
37 lines (33 loc) · 1.86 KB
/
oci-check-backups.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Fred Denis -- Oct 2019 -- http://unknowndba.blogspot.com -- [email protected]
#
# Show a status of the backups of the databases running on an OCI server
#
# Dev
N=4
for X in `dbcli list-databases | tac | awk '{if ($1 ~ /^--------/) {exit;} else {print $2;}}' | sort`
do
dbcli list-jobs | grep -i $X | tail -$N |\
awk -v DB="$X" 'BEGIN {failed=0;}
{ if ($0 ~ /Failure/)
{
"dbcli describe-job -i "$1 " | grep Message " | getline err ;
sub(/^ *Message:/, "", err);
printf("\033[1;36m%s\033[m\n", "=>" err) ;
printf("\033[1;31m%s\033[m\n", $0) ;
failed++ ;
} else
{ print $0 ;
}
} END\
{ for (i=1;i<=80;i++)
{ printf("\033[1;37m%s\033[m", "-") ;
}
printf("\n") ;
printf("\033[1;37m%s\033[m", "*** " DB " backup jobs *** -- ") ;
printf("\033[1;31m%s\033[m\n", failed " failures" ) ;
}' | tac
done
#********************************************************************************************************#
# E N D O F S O U R C E *#
#********************************************************************************************************#