Docker-Elasticsearch-backup-azure

container to backup your elasticserch database's to Microsoft Azure Storare.

Initial setup on elasticsearch server before backup

To work with Azure Repository, the Azure Repository plugin from the official ES Repository Plugin home page is to be installed on the machine running Elasticsearch.

Please refer to the following documentations related to usage and settings as provided by Elasticsearch.

Environment Variables

  • $CONTAINER - Container name in azure
  • $AZURE_STORAGE_ACCOUNT - Name of Azure Storare Account
  • $AZURE_STORAGE_ACCESS_KEY - Acess Key for Storage Account
  • $ELASTICSEARCH_PORT - Port to connect with elasticsearch. default 3306
  • $ELASTICSEARCH_HOST - Host where elasticsearch is running
  • $FILENAME - Name to file in Azure Storage. Default name default-date +"%Y-%m-%d_%H-%M" output example default-2015-08-03_17-58
  • $ONE_SHOOT - If true the container make the backup and exit, else the container still running and schedule a job in crontab. default false a backup window.
  • $DEBUG - If true will give you the value of all variables in terminal. default to false

To run the docker image

docker run ---rm --name elasticsearch-backup \
-e "ONE_SHOOT=true" \
-e "FILENAME=backup"
-e "AZURE_STORAGE_ACCOUNT=teste-azure"
-e "AZURE_STORAGE_ACCESS_KEY=ashdgashdgasdsa--dadcdsfsd/sdfd--"
-e "CONTAINER=sql-backup" \
-e "ELASTICSEARCH_HOST=test.elasticsearch.com" \
alvyl/docker-elasticsearch-backup-azure

This will upload to Azure Storare a file named default-2018-06-07_12-19-29.tar.gz and after that the container will stop.

Building image

docker build -t alvyl/docker-elasticsearch-backup-azure .

NOTE: This code is tested in v2.4 and version - 6.3


Steps for Elasticsearch backup in v2.4.X

  1. For elasticsearch 2.4 version we have to install elasticsearch driver. Run the following command from the elastic search installation folder. sudo bin/plugin install cloud-azure

  2. To enable Azure repositories, you have first to set your azure storage settings in elasticsearch.yml file

    cloud:
        azure:
            storage:
                my_account:
                    account: your_azure_storage_account
                    key: your_azure_storage_key
  3. For latest es version, please refer to the official documentations.

Useful links for v2.4

  1. Repository Plugin Home: https://www.elastic.co/guide/en/elasticsearch/plugins/2.4/repository.html
  2. Azure Plugin: https://www.elastic.co/guide/en/elasticsearch/plugins/2.4/cloud-azure-repository.html