for c in $(echo "$ociCompartmentList" | jq '.data | keys | .[]')
do
compartment_ocid=$(echo "$ociCompartmentList" | jq -r ".data[$c].\"id\"")
ocidbList=$(oci db database list -c $compartment_ocid)
for i in $(echo "$ocidbList" | jq '.data | keys | .[]')
do
dbid=$(echo "$ocidbList" | jq -r ".data[$i].\"id\"")
dbrole=$(oci db data-guard-association list --database-id $dbid| jq -r ".data[].\"role\"")
if [ -z $dbrole ]
then
echo "Stand alone Database , No Role Assigned , Setting to Primary"
dbrole="PRIMARY"
fi
if [ $dbrole == "PRIMARY" ]
then
dbname=$(echo "$ocidbList" | jq -r ".data[$i].\"db-name\"")
dbsystemid=$(echo "$ocidbList" | jq -r ".data[$i].\"db-system-id\"")
dbbackupconfig=$(echo "$ocidbList" | jq -r ".data[$i].\"db-backup-config\"")
dbautoBackupEnabled=$(echo "$dbbackupconfig" | jq -r ".\"auto-backup-enabled\"")
dbrecoveryWindow=$(echo "$dbbackupconfig" | jq -r ".\"recovery-window-in-days\"")
hostname=$(oci db node list -c $compartment_ocid --db-system-id $dbsystemid| jq -r ".data[].\"hostname\"")
if [ $dbautoBackupEnabled == "true" ]
then
echo "Hostname: $hostname | Database: $dbname | AutoBackup: $dbautoBackupEnabled | SUCCESS"
else
echo "Hostname: $hostname | Database: $dbname | AutoBackup: $dbautoBackupEnabled | FAILURE"
fi
if [ $dbrecoveryWindow == "30" ]
then
echo "Hostname: $hostname | Database: $dbname | RecoveryWindow: $dbrecoveryWindow | SUCCESS"
else
echo "Hostname: $hostname | Database: $dbname | RecoveryWindow: $dbrecoveryWindow | FAILURE"
fi
else
echo "Hostname: $hostname | Database: $dbname | Role : $dbrole - Skipping"
fi
done
done