First attempt at fixing this pg_dumpall/restoring issue

This commit is contained in:
Nathan Beals 2020-04-10 09:20:00 -04:00
parent fb4305a953
commit b14f371c05

View file

@ -93,14 +93,25 @@ def restore_database_dumps(databases, log_prefix, location_config, dry_run):
dump_filename = dump.make_database_dump_filename( dump_filename = dump.make_database_dump_filename(
make_dump_path(location_config), database['name'], database.get('hostname') make_dump_path(location_config), database['name'], database.get('hostname')
) )
restore_command = ( if database['name'] == 'all':
('pg_restore', '--no-password', '--clean', '--if-exists', '--exit-on-error') restore_command = (
+ (('--host', database['hostname']) if 'hostname' in database else ()) ('psql', '--no-password', '--clean', '--if-exists', '--exit-on-error')
+ (('--port', str(database['port'])) if 'port' in database else ()) + (('--host', database['hostname']) if 'hostname' in database else ())
+ (('--username', database['username']) if 'username' in database else ()) + (('--port', str(database['port'])) if 'port' in database else ())
+ ('--dbname', database['name']) + (('--username', database['username']) if 'username' in database else ())
+ (dump_filename,) + ('--dbname', database['name'])
) + (dump_filename,)
)
else:
restore_command = (
('pg_restore', '--no-password', '--clean', '--if-exists', '--exit-on-error')
+ (('--host', database['hostname']) if 'hostname' in database else ())
+ (('--port', str(database['port'])) if 'port' in database else ())
+ (('--username', database['username']) if 'username' in database else ())
+ ('--dbname', database['name'])
+ (dump_filename,)
)
extra_environment = {'PGPASSWORD': database['password']} if 'password' in database else None extra_environment = {'PGPASSWORD': database['password']} if 'password' in database else None
analyze_command = ( analyze_command = (
('psql', '--no-password', '--quiet') ('psql', '--no-password', '--quiet')