Use psql instead of pg_restore when format is "plain"
pg_restore: error: input file appears to be a text format dump. Please use psql.
This commit is contained in:
parent
f0f43174c6
commit
17f122bfe5
1 changed files with 5 additions and 3 deletions
|
@ -216,15 +216,17 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run,
|
||||||
+ (tuple(database['analyze_options'].split(' ')) if 'analyze_options' in database else ())
|
+ (tuple(database['analyze_options'].split(' ')) if 'analyze_options' in database else ())
|
||||||
+ ('--command', 'ANALYZE')
|
+ ('--command', 'ANALYZE')
|
||||||
)
|
)
|
||||||
|
use_psql_command = all_databases or database.get('format') == 'plain'
|
||||||
pg_restore_command = shlex.split(database.get('pg_restore_command') or 'pg_restore')
|
pg_restore_command = shlex.split(database.get('pg_restore_command') or 'pg_restore')
|
||||||
restore_command = (
|
restore_command = (
|
||||||
tuple(psql_command if all_databases else pg_restore_command)
|
tuple(psql_command if use_psql_command else pg_restore_command)
|
||||||
+ ('--no-password',)
|
+ ('--no-password',)
|
||||||
+ (
|
+ (
|
||||||
('--no-psqlrc', '--set', 'ON_ERROR_STOP=on')
|
('--no-psqlrc', '--set', 'ON_ERROR_STOP=on')
|
||||||
if all_databases
|
if use_psql_command
|
||||||
else ('--if-exists', '--exit-on-error', '--clean', '--dbname', database['name'])
|
else ('--if-exists', '--exit-on-error', '--clean')
|
||||||
)
|
)
|
||||||
|
+ (('--dbname', database['name']) if not all_databases else ())
|
||||||
+ (('--host', database['hostname']) if 'hostname' in database else ())
|
+ (('--host', database['hostname']) if 'hostname' in database else ())
|
||||||
+ (('--port', str(database['port'])) if 'port' in database else ())
|
+ (('--port', str(database['port'])) if 'port' in database else ())
|
||||||
+ (('--username', database['username']) if 'username' in database else ())
|
+ (('--username', database['username']) if 'username' in database else ())
|
||||||
|
|
Loading…
Reference in a new issue