4 Performing OCNADD Backup Procedures
Performing OCNADD Manual Backup
Perform the following steps to take the manual backup:
- Go to
custom-templates
folder inside the extracted ocnadd-release package and update theocnadd_manualBackup.yaml
file with the following information:- Values for BACKUP_DATABASES can be set to ALL (i.e. healthdb_schema, configuration_schema, and alarm_schema) or the individual DB names can also be passed. By default, the value is 'ALL'.
- Update other values as
follows:
apiVersion:batch/v1 kind:Job metadata: name:ocnaddmanualbackup namespace:ocnadd-deploy #---> update the namespace spec: template: metadata: name:ocnaddmanualbackup spec: volumes: -name:backup-vol persistentVolumeClaim: claimName:backup-mysql-pvc -name:config-vol configMap: name:config-backuprestore-scripts serviceAccountName:ocnadd-deploy-gitlab-admin #---> update the service account name. Format:<namespace>-gitlab-admin containers: -name:ocnaddmanualbackup image:<repo-path>/ocnaddbackuprestore:1.0.0 #---> update repository path volumeMounts: -mountPath:"work-dir" name:backup-vol -mountPath:"config-backuprestore-scripts" name:config-vol env: -name:HOME value:/tmp -name:DB_USER valueFrom: secretKeyRef: name:db-secret key:MYSQL_USER -name:DB_PASSWORD valueFrom: secretKeyRef: name:db-secret key:MYSQL_PASSWORD -name:BACKUP_DATABASES value:ALL command: - /bin/sh - -c - | cp /config-backuprestore-scripts/*.sh /tmp chmod +x /tmp/*.sh mkdir/work-dir/backup touch/work-dir/backup/DB_BACKUP_$(date +%d-%m-%Y_%H-%M-%S).sql echo "Executing manual backup script" bash /tmp/backup.sh $BACKUP_DATABASES ls -lh /work-dir/backup restartPolicy:Never status:{}
- Execute the below command to run the
job:
kubectl create -f ocnadd_manualBackup.yaml
Verifying OCNADD Backup
Caution:
The connectivity between the external storage via either PV/PVC or network connectivity must be ensured.
To verify the backup, perform the following steps:
- Go to the
custom-templates
folder inside the extracted ocnadd-release package and update theocnadd_verify_backup.yaml
file with the following information:- Sleep time is configurable, update it if required. (default sleep is 10m)
-
Update other values as follows:
apiVersion: batch/v1 kind: Job metadata: name: ocnaddverify namespace: ocnadd-deploy #---> update the namespace spec: template: metadata: name: ocnaddverify spec: volumes: - name: backup-vol persistentVolumeClaim: claimName: backup-mysql-pvc - name: config-vol configMap: name: config-backuprestore-scripts serviceAccountName: ocnadd-deploy-gitlab-admin #---> update the service account name. Format:<namespace>-gitlab-admin containers: - name: ocnaddverify image: <repo-path>/ocnaddbackuprestore:1.0.0 #---> update repository path volumeMounts: - mountPath: "work-dir" name: backup-vol - mountPath: "config-mysql-scripts" name: config-vol env: - name: HOME value: /tmp - name: DB_USER valueFrom: secretKeyRef: name: db-secret key: MYSQL_USER - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-secret key: MYSQL_PASSWORD command: - /bin/sh - -c - | cp /config-backuprestore-scripts/*.sh /tmp chmod +x /tmp/*.sh echo "Checking backup path" ls -lh /work-dir/backup sleep 10m restartPolicy: Never status: {}
- Run the following command to run the verify job for
verifying the backup generated at the mounted PV by running inside the running
container:
kubectl create -f ocnadd_verify_backup.yaml
- If the external storage is used as PV/PVC, get inside the ocnaddverify
container using the following commands:
-
kubectl exec -it <verify_pod> -n <ocnadd namespace> -- bash
- Change the directory to
/work-dir/backup
and inside the latest backup folder OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss. - Verify the DB backup and Kafka metadata backup files
-
Obtain the OCNADD Backup files
- Run the Verifying OCNADD Backup procedure to spawn the
verify_pod
. - Get into the running
ocnaddverify
pod to identify and retrieve the desire backup folder with the following commands:- Access the
pod
kubectl exec -it <ocnaddverify-*> -n <namespace> -- bash
where namespace = namespace of ocnadd
ocnaddverify-* = is the verify pod in the namespace
- Change the directory to /work-dir/backup and identify the backup folder "OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss"
- Exit from the ocnaddverify pod
- Access the
pod
- Copy the backup from the pod to the local bastion server by copying the
OCNADD Database and kafka_metadata files from the ocnaddverify pod with the
following commands:
- Onbastion host create a folder with the name similar to backup folder "OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss"
- Change to the folder created in step a.
- Use below command to copy backup files from the ocnaddverify pod To copy
ocnadd Database
backup:
kubectl exec -n <namespace> <verify_pod> -- cat/work-dir/backup/OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss/DB_BACKUP_DD-MM-YYYY_hh-mm-ss.sql > DB_BACKUP_DD-MM-YYYY_hh-mm-ss.sql
Example:kubectl exec -n ocnadd ocnaddverify-ncczz -- cat/work-dir/backup/OCNADD_BACKUP_11-11-2022_16-54-05/DB_BACKUP_11-11-2022_16-54-05.sql > DB_BACKUP_11-11-2022_16-54-05.sql
To copy ocnadd Kafka metadata backup:kubectl exec -n <namespace> <verify_pod> -- cat/work-dir/backup/OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss/kafka_metadata_DD-MM-YYYY_hh-mm-ss.txt > kafka_metadata_DD-MM-YYYY_hh-mm-ss.txt
Example:
kubectl exec -n ocnadd ocnaddverify-ncczz -- cat/work-dir/backup/OCNADD_BACKUP_11-11-2022_16-54-05/kafka_metadata_11-11-2022_16-54-05.txt > kafka_metadata_11-11-2022_16-54-05.txt
where, namespace = namespace of ocnadd
verify_pod = is the verify pod in the namespace
Copy and Restore the OCNADD backup
- Get the ocnadd backup folder.
- Execute the Verifying OCNADD Backup procedure to spawn the verify_pod.
- Create a folder inside the verify_pod under directory path:/work-dir/backup/ with
the name similar to the backup folder "OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss" .
- Access the pod with "kubectl exec -it <ocnaddverify-*> -n <namespace> -- bash".
- Create backup folder using command "mkdir -p /work-dir/backup/OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss".
- Copy the backup files from the local bastion server to the running
ocnaddverify pod.
- Go to the ocnadd backup directory
- Use the following command to copy backup files inside the ocnaddverify
pod:
cat DB_BACKUP_DD-MM-YYYY_hh-mm-ss.sql | kubectl exec -i -n <namespace> <verify_pod> -- bash -c "cat > /work-dir/backup/OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss/DB_BACKUP_DD-MM-YYYY_hh-mm-ss.sql
Example:
cat DB_BACKUP_11-11-2022_16-54-05.sql | kubectl exec -i -n ocnadd ocnaddverify-ncczz -- bash -c "cat > /work-dir/backup/OCNADD_BACKUP_11-11-2022_16-54-05/DB_BACKUP_11-11-2022_16-54-05.sql
- To copy ocnadd Kafka metadata backup:
cat kafka_metadata_DD-MM-YYYY_hh-mm-ss.txt | kubectl exec -i -n <namespace> <verify_pod> -- bash -c "cat > /work-dir/backup/OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss/kafka_metadata_DD-MM-YYYY_hh-mm-ss.txt
Example:
cat kafka_metadata_11-11-2022_16-54-05.txt | kubectl exec -i -n ocnadd ocnaddverify-ncczz -- bash -c "cat > /work-dir/backup/OCNADD_BACKUP_11-11-2022_16-54-05/kafka_metadata_11-11-2022_16-54-05.txt"
- Verify the backup has been copied by getting into the ocnaddverify pod and path: /work-dir/backup/OCNADD_BACKUP_DD-MM-YYYY_hh-mm-ss
- Restore OCNADD using the procedure defined in Create OCNADD Restore Job.
- Restart the ocnaddconfiguration, ocnaddalarm, and ocnaddhealthmonitoring pods.