bundles/postgresql: do a database dump before backing up the database
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
3d1468b214
commit
724537558e
3 changed files with 28 additions and 0 deletions
9
bundles/postgresql/files/backup-pre-hook
Normal file
9
bundles/postgresql/files/backup-pre-hook
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
target="/var/tmp/postgresdumps"
|
||||
|
||||
pg_dumpall --globals-only | gzip --quiet --rsyncable >"$target/globals.sql.gz"
|
||||
|
||||
% for db in sorted(databases):
|
||||
pg_dump -C "${db}" | gzip --quiet --rsyncable >"$target/db_${db}.sql.gz"
|
||||
% endfor
|
|
@ -56,6 +56,19 @@ files = {
|
|||
},
|
||||
}
|
||||
|
||||
# FIXME currently we do not have a mechanism to use snapshot-backups of
|
||||
# zfs datasets.
|
||||
if True: # not node.has_bundle('zfs') and node.has_bundle('backup-client'):
|
||||
files['/etc/backup-pre-hooks.d/90-postgresql-dump-all'] = {
|
||||
'source': 'backup-pre-hook',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'databases': node.metadata.get('postgresql', {}).get('databases', {}).keys(),
|
||||
},
|
||||
'mode': '0700',
|
||||
}
|
||||
directories['/var/tmp/postgresdumps'] = {}
|
||||
|
||||
postgres_roles = {
|
||||
'root': {
|
||||
'password': repo.vault.password_for('{} postgresql root'.format(node.name)),
|
||||
|
|
|
@ -2,6 +2,9 @@ defaults = {
|
|||
'backups': {
|
||||
'paths': {
|
||||
'/var/lib/postgresql',
|
||||
|
||||
# FIXME
|
||||
'/var/tmp/postgresdumps',
|
||||
},
|
||||
},
|
||||
'icinga2_api': {
|
||||
|
@ -32,6 +35,9 @@ if node.has_bundle('zfs'):
|
|||
},
|
||||
},
|
||||
}
|
||||
# FIXME
|
||||
#else:
|
||||
# defaults['backups']['paths'].add('/var/tmp/postgresdumps')
|
||||
|
||||
|
||||
@metadata_reactor.provides(
|
||||
|
|
Loading…
Reference in a new issue