Support PostgreSQL Custom Format (#63806)
* Support PGC Restores * Fix whitespace * support pgc both dump and restore
This commit is contained in:
parent
54b530967b
commit
fb38c9cea9
3 changed files with 10 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- postgresql_db - add support for .pgc file format for dump and restores.
|
|
@ -71,7 +71,7 @@ options:
|
||||||
pg_dump returns rc 1 in this case.
|
pg_dump returns rc 1 in this case.
|
||||||
- C(restore) also requires a target definition from which the database will be restored. (Added in Ansible 2.4)
|
- C(restore) also requires a target definition from which the database will be restored. (Added in Ansible 2.4)
|
||||||
- The format of the backup will be detected based on the target name.
|
- The format of the backup will be detected based on the target name.
|
||||||
- Supported compression formats for dump and restore include C(.bz2), C(.gz) and C(.xz)
|
- Supported compression formats for dump and restore include C(.pgc), C(.bz2), C(.gz) and C(.xz)
|
||||||
- Supported formats for dump and restore include C(.sql) and C(.tar)
|
- Supported formats for dump and restore include C(.sql) and C(.tar)
|
||||||
type: str
|
type: str
|
||||||
choices: [ absent, dump, present, restore ]
|
choices: [ absent, dump, present, restore ]
|
||||||
|
@ -346,6 +346,8 @@ def db_dump(module, target, target_opts="",
|
||||||
|
|
||||||
if os.path.splitext(target)[-1] == '.tar':
|
if os.path.splitext(target)[-1] == '.tar':
|
||||||
flags.append(' --format=t')
|
flags.append(' --format=t')
|
||||||
|
elif os.path.splitext(target)[-1] == '.pgc':
|
||||||
|
flags.append(' --format=c')
|
||||||
if os.path.splitext(target)[-1] == '.gz':
|
if os.path.splitext(target)[-1] == '.gz':
|
||||||
if module.get_bin_path('pigz'):
|
if module.get_bin_path('pigz'):
|
||||||
comp_prog_path = module.get_bin_path('pigz', True)
|
comp_prog_path = module.get_bin_path('pigz', True)
|
||||||
|
@ -392,6 +394,10 @@ def db_restore(module, target, target_opts="",
|
||||||
flags.append(' --format=Tar')
|
flags.append(' --format=Tar')
|
||||||
cmd = module.get_bin_path('pg_restore', True)
|
cmd = module.get_bin_path('pg_restore', True)
|
||||||
|
|
||||||
|
elif os.path.splitext(target)[-1] == '.pgc':
|
||||||
|
flags.append(' --format=Custom')
|
||||||
|
cmd = module.get_bin_path('pg_restore', True)
|
||||||
|
|
||||||
elif os.path.splitext(target)[-1] == '.gz':
|
elif os.path.splitext(target)[-1] == '.gz':
|
||||||
comp_prog_path = module.get_bin_path('zcat', True)
|
comp_prog_path = module.get_bin_path('zcat', True)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
- dbdata.tar.gz
|
- dbdata.tar.gz
|
||||||
- dbdata.tar.bz2
|
- dbdata.tar.bz2
|
||||||
- dbdata.tar.xz
|
- dbdata.tar.xz
|
||||||
|
- dbdata.pgc
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: loop_item
|
loop_var: loop_item
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue