MySQL-backup-to-azure is a docker container that will connect to your specified MySQL server, create a database dump of all your databases and write the contents to Azure Blob Storage.


  • Azure Storage Account - you'll need to of created the storage account and create a container inside of it. Make a note of the storage account name and key.
  • Kubernetes or Docker Enviromment.


Docker is very easy to setup, you can schedule a cronjob to run at your desired backup interval.

docker run -it --rm -e mysql_host=mysql -e mysql_user=root -e mysql_password=changeme -e azure_account=testblob -e azure_accountKey=changeme -e azure_container=backup adamhancock/mysql-backup-to-azure
Running the container


Kubernetes has the ability to run its own cronjobs. The below instructions schedule the container to run at midnight daily.

Create the following YAML and update the values to your MySQL server and Azure Storage Account Credentials.

apiVersion: v1
kind: Secret
  name: mysql-backup
type: Opaque
  host: mysql
  user: root
  password: changeme
apiVersion: v1
kind: Secret
  name: azure
type: Opaque
  account: changeme
  accountKey: changeme
  container: backup
kubectl apply -f secrets.yml
Apply the secrets to your K8s Server

Next we need to create the Kubernetes cronjob. You can apply this directly from the GitHub Repository.

kubectl apply -f

The default schedule will run at midnight daily. This can be updated by editing the schedule value inside the K8s cronjob.

kubectl edit cj mysql-backup-to-azure
Edit the K8s Cronjob