mirror of
https://github.com/roles-ansible/role-postgresql-backup.git
synced 2024-08-16 10:19:49 +02:00
install tar and gzip if needed
This commit is contained in:
parent
6c33640a34
commit
d26daa76a1
4 changed files with 16 additions and 1 deletions
|
@ -6,6 +6,9 @@ postgresql_backup:
|
|||
required_packages:
|
||||
- postgresql-client
|
||||
- cron
|
||||
optional_packages:
|
||||
- tar
|
||||
- gzip
|
||||
backup_dir: /var/backup/postgresql
|
||||
date_format: '%Y-%m-%d_%H-%M'
|
||||
user: root
|
||||
|
|
|
@ -4,3 +4,10 @@
|
|||
package:
|
||||
name: "{{ postgresql_backup.required_packages }}"
|
||||
state: present
|
||||
|
||||
- name: "Install tar and gzip"
|
||||
become: true
|
||||
package:
|
||||
name: "{{ postgresql_backup.optional_packages }}"
|
||||
state: present
|
||||
when: postgresql_backup.create_tar_gz | bool
|
||||
|
|
|
@ -20,7 +20,9 @@ backup_databases() {
|
|||
{% endif %}
|
||||
if (umask 077 && pg_dump -F {{ postgresql_backup.export_option | string }} -h "{{ db.host | default( 'localhost' ) }}" -U "{{ db.user | default( 'postgres' ) }}" -p "{{ db.port | default( '5432' ) }}" "{{ db.name }}" -f "{{ db.name }}.in_progress.psql"); then
|
||||
{% if postgresql_backup.create_tar_gz %}
|
||||
mv "{{ db.name }}.in_progress.psql" "{{ db.name }}.psql"
|
||||
tar -czvf "{{ db.name }}.psql.tar.gz" "{{ db.name }}.in_progress.psql"
|
||||
rm "{{ db.name }}.psql"
|
||||
{% else %}
|
||||
mv "{{ db.name }}.in_progress.psql" "{{ db.name }}.psql"
|
||||
{% endif %}
|
||||
|
|
|
@ -3,6 +3,9 @@ _postgresql_backup:
|
|||
required_packages:
|
||||
- postgresql-client
|
||||
- cron
|
||||
optional_packages:
|
||||
- tar
|
||||
- gzip
|
||||
backup_dir: /var/backup/postgresql
|
||||
date_format: '%Y-%m-%d_%H-%M'
|
||||
user: root
|
||||
|
@ -14,5 +17,5 @@ _postgresql_backup:
|
|||
databases: []
|
||||
|
||||
# versionscheck
|
||||
playbook_version_number: 22 # should be int
|
||||
playbook_version_number: 23 # should be int
|
||||
playbook_version_path: 'role-postgresql-backup_roles-ansible_github.com.version' # unique string
|
||||
|
|
Loading…
Add table
Reference in a new issue