key: dedicated operator: Exists volumes: - name: backup persistentVolumeClaim: claimName: core-backup - name: cluster-ca secret: secretName: cluster-ca-cert - name: mongodb-certs secret: secretName: icp-mongodb-client-cert restartPolicy: Never backoffLimit: 1 

Alternatively, download the file from the following link: 

https://github.com/IBMRedbooks/SG248440-IBM-Cloud-Private-System-Administrator- s-Guide/tree/master/Ch3-Backup-and-Restore/Backup/mongodb-backup_job.yaml 

The ibmcom/icp-mongodb:4.0.5 image is the default MongoDB image for IBM Cloud Private 3.1.2. If the environment does not have internet access, replace ibmcom  with the private image registry local to the cluster, for example: mycluster.icp:8500/ibmcom/icp-mongodb:4.0.5 . 

3. Create the job: 

[root@icp-ha-boot ~]# kubectl create -f mongodb-backup_job.yaml job.batch "mongodbdump" created 

4. Verify that the job was successful: 

[root@icp-ha-boot ~]# kubectl get jobs mongodbdump NAME DESIRED SUCCESSFUL AGE mongodbdump 1 1 3m 

5. Verify that the etcd snapshot exists: 

[root@lf-icp-nfs mongodb]# ls -sh mongodbdump* 976K mongodbdump-2019-02-26_05:58:22.gz 

## Backing up MariaDB 

MariaDB in IBM Cloud Private is only used for storing the transient OpenIDConnect data. The default refresh period for user tokens is 12 hours. If this data is lost between restores, the data can simply be regenerated by logging in to the platform. If there is a use case to retain the MariaDB data, you can back up the database using kubectl or a Kubernetes job. 

## Backing up MariaDB using kubectl 

Perform the following steps on any machine that has kubectl  configured to access to the cluster: 

1. Get the MariaDB pod name: 

[root@icp-ha-boot ~]# kubectl -n kube-system get pods -l release=mariadb -o=jsonpath='{.items[0].metadata.name}' mariadb-0 

2. Run the mysql command: 

[root@icp-ha-boot ~]# kubectl -n kube-system exec -it mariadb-0 -c mariadb -- sh -c 'mysqldump --host=$MARIADB_SERVICE_HOST --user=root --password=$MYSQL_ROOT_PASSWORD --all-databases > /backup.sql' 

