diff --git a/edb_mustgather.sh b/edb_mustgather.sh index 1572bf0..afc3a33 100755 --- a/edb_mustgather.sh +++ b/edb_mustgather.sh @@ -66,7 +66,8 @@ fi MGMT_CR_NAME=$($KUBECTL get mgmt -n ${EDB_CLUSTER_NAMESPACE} -o=jsonpath='{.items[0].metadata.name}') EDB_CLUSTER_NAME=$($KUBECTL get cluster -n ${EDB_CLUSTER_NAMESPACE} -o=jsonpath='{.items[?(@.metadata.ownerReferences[0].name=="'${MGMT_CR_NAME}'")].metadata.name}') EDB_POD_NAMES=$($KUBECTL get pod -l k8s.enterprisedb.io/cluster=${EDB_CLUSTER_NAME} -L role -n ${EDB_CLUSTER_NAMESPACE} -o=custom-columns=NAME:.metadata.name --no-headers) -EDB_BACKUP_NAMES=$($KUBECTL get backups -l k8s.enterprisedb.io/cluster=${EDB_CLUSTER_NAME} -L role -n ${EDB_CLUSTER_NAMESPACE} -o=custom-columns=NAME:.metadata.name --no-headers) +EDB_BACKUP_NAMES=$($KUBECTL get backups -o=jsonpath='{.items[?(@.spec.cluster.name=="'${EDB_CLUSTER_NAME}'")]}' -L role -n ${EDB_CLUSTER_NAMESPACE} -o=custom-columns=NAME:.metadata.name --no-headers) +EDB_SCHEDULED_BACKUP_NAMES=$($KUBECTL get scheduledBackups -o=jsonpath='{.items[?(@.spec.cluster.name=="'${EDB_CLUSTER_NAME}'")]}' -n ${EDB_CLUSTER_NAMESPACE} -o=custom-columns=NAME:.metadata.name --no-headers) K8S_DATA="${TEMP_PATH}/kubernetes" K8S_NAMESPACES="${K8S_DATA}/namespaces" K8S_NAMESPACES_SPECIFIC="${K8S_NAMESPACES}/${EDB_OP_NAMESPACE}" @@ -81,6 +82,7 @@ OPERATOR_PODS=${SPECIFIC_NS_EDB_OP}/pods CLUSTER=${SPECIFIC_NS_CLUSTER}/cluster CLUSTER_PODS=${SPECIFIC_NS_CLUSTER}/pods CLUSTER_BACKUPS=${SPECIFIC_NS_CLUSTER}/backups +CLUSTER_SCHEDULED_BACKUPS=${SPECIFIC_NS_CLUSTER}/scheduledbackups mkdir ${NS} @@ -92,6 +94,8 @@ mkdir ${CLUSTER}/${EDB_CLUSTER_NAME} mkdir -p ${CLUSTER_PODS} mkdir ${CLUSTER_BACKUPS} mkdir ${CLUSTER_BACKUPS}/${EDB_CLUSTER_NAME} +mkdir ${CLUSTER_SCHEDULED_BACKUPS} +mkdir ${CLUSTER_SCHEDULED_BACKUPS}/${EDB_CLUSTER_NAME} function gatherEdbOperatorData() { $KUBECTL cnp report operator --logs -n ${EDB_OP_NAMESPACE} -f ${SPECIFIC_NS_EDB_OP}/operator-report.zip @@ -110,9 +114,9 @@ function gatherClusterData() { $KUBECTL cnp status ${EDB_CLUSTER_NAME} -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/status.txt $KUBECTL cnp status ${EDB_CLUSTER_NAME} --verbose -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/status-verbose.txt - $KUBECTL get cluster -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/info.txt - $KUBECTL get cluster -o yaml -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/cluster.yaml - $KUBECTL describe cluster -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/describe.txt + $KUBECTL get cluster ${EDB_CLUSTER_NAME} -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/info.txt + $KUBECTL get cluster ${EDB_CLUSTER_NAME} -o yaml -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/cluster.yaml + $KUBECTL describe cluster ${EDB_CLUSTER_NAME} -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/describe.txt } @@ -131,7 +135,7 @@ function gatherEDBPodData() { } function gatherEDBBackupData() { - $KUBECTL get backups -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER_BACKUPS}/${EDB_CLUSTER_NAME}/backups.txt + $KUBECTL get backups -n ${EDB_CLUSTER_NAMESPACE} -o=jsonpath='{.items[?(@.spec.cluster.name=="'${EDB_CLUSTER_NAME}'")]}' -o wide > ${CLUSTER_BACKUPS}/${EDB_CLUSTER_NAME}/backups.txt for backup in ${EDB_BACKUP_NAMES}; do mkdir ${CLUSTER_BACKUPS}/${EDB_CLUSTER_NAME}/${backup} $KUBECTL get backups ${backup} -o yaml -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER_BACKUPS}/${EDB_CLUSTER_NAME}/${backup}/backup.yaml @@ -139,6 +143,15 @@ function gatherEDBBackupData() { done } +function gatherEDBScheduledBackupData() { + $KUBECTL -n ${EDB_CLUSTER_NAMESPACE} get scheduledbackups -o=jsonpath='{.items[?(@.spec.cluster.name=="'${EDB_CLUSTER_NAME}'")]}' -o wide > ${CLUSTER_SCHEDULED_BACKUPS}/${EDB_CLUSTER_NAME}/scheduledbackups.txt + for scheduledbackup in ${EDB_SCHEDULED_BACKUP_NAMES}; do + mkdir ${CLUSTER_SCHEDULED_BACKUPS}/${EDB_CLUSTER_NAME}/${scheduledbackup} + $KUBECTL -n ${EDB_CLUSTER_NAMESPACE} get scheduledbackups ${scheduledbackup} -o yaml > ${CLUSTER_SCHEDULED_BACKUPS}/${EDB_CLUSTER_NAME}/${scheduledbackup}/backup.yaml + $KUBECTL -n ${EDB_CLUSTER_NAMESPACE} describe scheduledbackups ${scheduledbackup} > ${CLUSTER_SCHEDULED_BACKUPS}/${EDB_CLUSTER_NAME}/${scheduledbackup}/describe.txt + done +} + if [[ -z "$PG_OP" ]]; then @@ -166,3 +179,9 @@ if [[ -z "$EDB_BACKUP_NAMES" ]]; then else gatherEDBBackupData fi + +if [[ -z "$EDB_SCHEDULED_BACKUP_NAMES" ]]; then + echo "failed to find the edb cluster scheduledBackups in the ${EDB_CLUSTER_NAMESPACE} namespace" +else + gatherEDBScheduledBackupData +fi