20 lines
900 B
YAML
20 lines
900 B
YAML
---
|
|
- name: 'Create timer for database backup'
|
|
include_role: name=systemd-timer
|
|
vars:
|
|
systemd_timer_name: '{{ postgres_ha_backup_service_name }}'
|
|
systemd_timer_description: 'Dump Telemetry PostgreSQL database.'
|
|
systemd_timer_user: '{{ postgres_ha_backup_user }}'
|
|
systemd_timer_frequency: '{{ postgres_ha_backup_frequency }}'
|
|
systemd_timer_timeout_sec: '{{ postgres_ha_backup_timeout }}'
|
|
systemd_timer_after_extra: 'docker.service'
|
|
systemd_timer_start_on_creation: false
|
|
systemd_timer_script_content: |
|
|
#!/usr/bin/env bash
|
|
BKP_DIR="{{ postgres_ha_cont_data_vol }}/backup/{{ postgres_ha_db_name }}"
|
|
rm -vfr "${BKP_DIR}"
|
|
/usr/bin/docker exec -i {{ postgres_ha_cont_name }} \
|
|
pg_dump -F directory -f "/backup/{{ postgres_ha_db_name }}" \
|
|
-U {{ postgres_ha_admin_user }} {{ postgres_ha_db_name }}
|
|
chmod 750 -R "${BKP_DIR}"
|