If you have ever used backups with Percona Distribution for MongoDB Operator, you should already know that backed-up data is stored outside the Kubernetes cluster – on Amazon S3 or any S3-compatible storage. Storage types not compatible with the S3 protocol were supported indirectly in the case of an existing S3 wrapper/gateway. A good example of such a solution is running MinIO Gateway on Azure Kubernetes Service to store backups on Azure Blob Storage.
Starting with Operator version 1.11, it is now possible to use Azure Blob Storage for backups directly:
The following steps will allow you to configure it.
1. Get Azure Blob Storage Credentials
As with most other S3-compatible storage types, the first thing to do is to obtain credentials the Operator will use to access Azure Blob storage.
If you are new to Azure, these two tutorials will help you to configure your storage:
- create your storage account: Create a storage account – Azure Storage,
- create a container within it: Quickstart: Upload, download, and list blobs – Azure portal – Azure Storage.
When you have a container to store your backups, getting credentials to access it involve the following steps:
- Go to your storage account settings,
- Open the “Access keys” section,
- Copy and save both the account name and account key as shown on a screenshot below:
2. Create a Secret with Credentials
The Operator will use a Kubernetes Secrets Object to obtain the needed credentials. Create this Secret with credentials using the following command:
1 2 3 |
$ kubectl create secret generic azure-secret --from-literal=AZURE_STORAGE_ACCOUNT_NAME=<your-storage-account-name> --from-literal=AZURE_STORAGE_ACCOUNT_KEY=<your-storage-key> |
3. Setup spec.backup Section in your deploy/cr.yaml file
As usual, backups are configured via the same-name section in the deploy/cr.yaml configuration file.
Make sure that backups are enabled (backup.enable key set to true), and add the following lines to the backup.storages subsection (use the proper name of your container):
1 2 3 4 5 6 |
azure-blob: type: azure azure: container: <your-container-name> prefix: psmdb credentialsSecret: azure-secret |
If you want to schedule a regular backup, add the following lines to the backup.tasks subsection:
1 2 3 4 5 6 |
tasks: - name: weekly enabled: true schedule: "0 0 * * 0" compressionType: gzip storageName: azure-blob |
The backup schedule is specified in crontab format (the above example runs backups at 00:00 on Sunday). If you know nothing about cron schedule expressions, you can use this online generator.
The full backup section in our example will look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
backup: enabled: true restartOnFailure: true image: percona/percona-server-mongodb-operator:1.10.0-backup storages: azure-blob: type: azure azure: container: <your container name> prefix: psmdb credentialsSecret: azure-secret tasks: - name: weekly enabled: true schedule: "0 0 * * 0" compressionType: gzip storageName: azure-blob |
You can find more information on backup options in the official backups documentation and the backups section of the Custom Resource options reference.
Percona Distribution for MongoDB is a freely available MongoDB database alternative, giving you a single solution that combines the best and most important enterprise components from the open source community, designed and tested to work together.
Download Percona Distribution for MongoDB Today!