sebastian13.docker-db-dump
Ansible Docker Database Dump
This playbook deploys backups scripts to backup docker container running a mysql or postgres database. It deploys the scripts docker-mysql-dump.sh and docker-postgres-dump.sh, and creates entries in crontab to run the scripts each morning.
How to use
Clone this repo in
rolescd roles git clone https://github.com/sebastian13/ansible-docker-db-dump.gitCreate a playbook
docker-db-dump.yml--- - name: Docker Databse Dump hosts: "{{ hostname | default('docker-db-dump') }}" become: true roles: - docker-db-dumpDefine hosts in the
hostsfile[docker-db-dump] v01 v02Create a file for each host in
host_varsdocker_mysql: - name: wordpress.example.com path: '/docker/wordpress.example.com' - name: joomla.example.com path: '/docker/joomla.example.com' docker_postgres: - name: confluence.example.com path: '/docker/confluence.example.com'Run the playbook. Optionally limit the deployment to a single server.
ansible-playbook docker-db-dump.yml --limit v01
Requirements
The docker-compose.yml within the specified path must include a service called mysql or postgres. The environment varaibles must be linked and specified in the file .env.
Example
docker-compose.ymlservices: mysql: image: mariadb env_file: .env other: image: wordpress environment: - WORDPRESS_DB_PASSWORD=${MYSQL_ROOT_PASSWORD} - WORDPRESS_DB_NAME=${MYSQL_DATABASE}services: postgres: image: postgres:9.6 env_file: .envExample
.envMYSQL_DATABASE=example MYSQL_ROOT_PASSWORD=123456POSTGRES_USER=example POSTGRES_DB=example POSTGRES_PASSWORD=123456
About
Deploy backups scripts to create dumps of docker containers running mysql or postgres
Install
ansible-galaxy install sebastian13.docker-db-dumpLicense
gpl-3.0
Downloads
30
Owner
