Skip to content
Snippets Groups Projects
Commit 9cb5967f authored by jurgenhaas's avatar jurgenhaas
Browse files

mobimo/support#2991 Add backup with borg

parent 82bafd2a
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,31 @@
Private-Token: '{{ GITLAB_PRIVATE_TOKEN }}'
dest: '{{ appdir }}/app/{{ app.id }}.jar'
- name: Ensure Crontab Directory
file:
path: '{{ appdir }}/crontabs'
state: directory
when: app.dbimage is defined
- name: Configuration Crontabs
template:
src: maven/jobs.ini
dest: '{{ appdir }}/crontabs/jobs.ini'
mode: 0664
when: app.dbimage is defined
- name: Configure Backup
include_role:
name: borgbackup
tasks_from: app
vars:
application: docker
application_id: '{{ app.id }}'
application_remote_repo: 'ya0459m8@ya0459m8.repo.borgbase.com:repo'
application_root: '{{ appdir }}'
application_backup_source: '{{ appdir }}/dbbackup'
when: app.dbimage is defined
- name: Docker compose file
template:
src: maven/docker-compose.yml
......@@ -41,3 +66,9 @@
with_items:
- pull --quiet
- up -d
- name: Set Permissions in Container
command: dc exec -it -u root db chown -R mysql /var/backups/mysql
args:
chdir: '{{ appdir }}'
when: app.dbimage is defined
......@@ -28,4 +28,16 @@ services:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- {{ appdir }}/db:/var/lib/mysql
- {{ appdir }}/dbbackup:/var/backups/mysql
cron:
image: mcuadros/ofelia:latest
restart: unless-stopped
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- {{ appdir }}/crontabs/jobs.ini:/etc/ofelia/config.ini
borgmatic: {{ docker_compose_borgmatic_service }}
{% endif %}
[job-exec "Maven DB Backup: {{ app.id }}"]
no-overlap = true
tty = true
user = mysql
schedule = 0 30 0 * * *
container = {{ app.id }}-db-1
command = sh -c \"mysqldump -u root --password={{ app.id }} {{ app.id }} >/var/backups/mysql/{{ app.id }}.sql && {{ lookup('healthchecks', '', user='root', jobname=['Maven DB Backup ', app.id]|join(''), schedule='30 0 * * *', disabled=crons_disabled|default(false)) }}\"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment