mirror of
https://github.com/roles-ansible/role-postgresql-backup.git
synced 2024-08-16 10:19:49 +02:00
Change path and add compression
This commit is contained in:
parent
c6c36ac64f
commit
00e4de0225
4 changed files with 13 additions and 6 deletions
|
@ -10,6 +10,7 @@ postgresql_backup:
|
|||
user: root
|
||||
cron_minute: '*'
|
||||
cron_hour: '0'
|
||||
compress: false
|
||||
databases: []
|
||||
# - name: psql_database_name
|
||||
# user: psql_database_user
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
become: true
|
||||
template:
|
||||
src: templates/postgresql-backup-script.sh
|
||||
dest: /etc/postgresql-backup-script.sh
|
||||
dest: /opt/postgresql-backup-script.sh
|
||||
owner: "{{ postgresql_backup.user }}"
|
||||
backup: true
|
||||
mode: 0755
|
||||
|
@ -24,5 +24,5 @@
|
|||
cron_file: /etc/crontab
|
||||
minute: "{{ postgresql_backup.cron_minute | default( '*' ) }}"
|
||||
hour: "{{ postgresql_backup.cron_hour | default( '0' ) }}"
|
||||
job: /etc/postgresql-backup-script.sh
|
||||
job: /etc/postgresql-backup-script.sh >/dev/null 2>&1
|
||||
user: "{{ postgresql_backup.user }}"
|
||||
|
|
|
@ -19,8 +19,14 @@ backup_databases() {
|
|||
export PGPASSWORD="{{ db.password }}"
|
||||
{% endif %}
|
||||
if (umask 077 && pg_dump -F c -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.compress %}
|
||||
tar -czvf "{{ db.name }}.psql.tar.gz" "{{ db.name }}.in_progress.psql"
|
||||
{% else %}
|
||||
mv "{{ db.name }}.in_progress.psql" "{{ db.name }}.psql"
|
||||
{% endif %}
|
||||
echo "backup of {{ db.name }} successful"
|
||||
else
|
||||
echo "failed to export {{ db.name }}"
|
||||
return 1
|
||||
fi;
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
---
|
||||
# versionscheck
|
||||
playbook_version_number: 17 # should be int
|
||||
playbook_version_path: 'role-postgresql-backup_roles-ansible_github.com.version' # unique string
|
||||
|
||||
_postgresql_backup:
|
||||
required_packages:
|
||||
- postgresql-client
|
||||
|
@ -12,3 +8,7 @@ _postgresql_backup:
|
|||
cron_minute: '*'
|
||||
cron_hour: '0'
|
||||
databases: []
|
||||
|
||||
# versionscheck
|
||||
playbook_version_number: 18 # should be int
|
||||
playbook_version_path: 'role-postgresql-backup_roles-ansible_github.com.version' # unique string
|
||||
|
|
Loading…
Reference in a new issue