add db_dump backup timer
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
bf8662b20f
commit
6ed5ff3780
|
@ -5,6 +5,7 @@ postgres_ha_compose_file: '{{ postgres_ha_service_path }}/docker-compose.yml'
|
|||
|
||||
postgres_ha_cont_name: '{{ postgres_ha_service_name }}'
|
||||
postgres_ha_cont_data_vol: '{{ postgres_ha_service_path }}/data'
|
||||
postgres_ha_cont_backup_vol: '{{ postgres_ha_service_path }}/backup'
|
||||
postgres_ha_cont_image: 'postgres:15.1-alpine'
|
||||
postgres_ha_cont_port: 5432
|
||||
postgres_ha_cont_uid: 70
|
||||
|
@ -35,6 +36,12 @@ postgres_ha_databases: []
|
|||
# user: 'dbuser'
|
||||
# pass: 'dbpass'
|
||||
|
||||
# Backups
|
||||
postgres_ha_backup_service_name: 'dump-{{ telemetry_service_name }}-db'
|
||||
postgres_ha_backup_frequency: daily
|
||||
postgres_ha_backup_timeout: 600
|
||||
postgres_ha_backup_user: 'root'
|
||||
|
||||
# Consul
|
||||
postgres_ha_consul_service: 'postgres'
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- 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_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}"
|
|
@ -22,3 +22,4 @@
|
|||
loop_var: db
|
||||
|
||||
- import_tasks: consul.yml
|
||||
- import_tasks: backup.yml
|
||||
|
|
|
@ -21,6 +21,7 @@ services:
|
|||
- '/tmp:size={{ postgres_ha_cont_tmp_size }}'
|
||||
volumes:
|
||||
- '{{ postgres_ha_cont_data_vol }}:/var/lib/postgresql/data'
|
||||
- '{{ postgres_ha_cont_backup_vol }}/backup:/backup'
|
||||
command: |
|
||||
-p {{ postgres_ha_cont_port }}
|
||||
healthcheck:
|
||||
|
|
Loading…
Reference in New Issue