mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that Backup, Restore, and Maintenance should work properly when pgpass file is used. #6499
This commit is contained in:
@@ -437,7 +437,7 @@ def create_backup_objects_job(sid):
|
||||
*args,
|
||||
database=data['database']
|
||||
),
|
||||
cmd=utility, args=escaped_args
|
||||
cmd=utility, args=escaped_args, manager_obj=manager
|
||||
)
|
||||
else:
|
||||
p = BatchProcess(
|
||||
@@ -447,20 +447,10 @@ def create_backup_objects_job(sid):
|
||||
server.id, bfile,
|
||||
*args
|
||||
),
|
||||
cmd=utility, args=escaped_args
|
||||
cmd=utility, args=escaped_args, manager_obj=manager
|
||||
)
|
||||
|
||||
manager.export_password_env(p.id)
|
||||
# Check for connection timeout and if it is greater than 0 then
|
||||
# set the environment variable PGCONNECT_TIMEOUT.
|
||||
timeout = manager.get_connection_param_value('connect_timeout')
|
||||
if timeout and int(timeout) > 0:
|
||||
env = dict()
|
||||
env['PGCONNECT_TIMEOUT'] = str(timeout)
|
||||
p.set_env_variables(server, env=env)
|
||||
else:
|
||||
p.set_env_variables(server)
|
||||
|
||||
p.set_env_variables(server)
|
||||
p.start()
|
||||
jid = p.id
|
||||
except Exception as e:
|
||||
|
||||
@@ -328,15 +328,10 @@ def create_import_export_job(sid):
|
||||
*args,
|
||||
**io_params
|
||||
),
|
||||
cmd=utility, args=args
|
||||
cmd=utility, args=args, manager_obj=manager
|
||||
)
|
||||
manager.export_password_env(p.id)
|
||||
|
||||
env = dict()
|
||||
|
||||
if manager.service:
|
||||
env['PGSERVICE'] = manager.service
|
||||
|
||||
env['PGHOST'] = \
|
||||
manager.local_bind_host if manager.use_ssh_tunnel else server.host
|
||||
env['PGPORT'] = \
|
||||
@@ -350,14 +345,6 @@ def create_import_export_job(sid):
|
||||
if value is None:
|
||||
del env[key]
|
||||
|
||||
# Export PGPASSFILE to work with PGPASSFILE authenthification
|
||||
if manager.connection_params \
|
||||
and isinstance(manager.connection_params, dict):
|
||||
if 'passfile' in manager.connection_params \
|
||||
and manager.connection_params['passfile']:
|
||||
env['PGPASSFILE'] = get_complete_file_path(
|
||||
manager.connection_params['passfile'])
|
||||
|
||||
p.set_env_variables(server, env=env)
|
||||
p.start()
|
||||
jid = p.id
|
||||
|
||||
@@ -246,19 +246,9 @@ def create_maintenance_job(sid, did):
|
||||
try:
|
||||
p = BatchProcess(
|
||||
desc=Message(server.id, data, query),
|
||||
cmd=utility, args=args
|
||||
cmd=utility, args=args, manager_obj=manager
|
||||
)
|
||||
manager.export_password_env(p.id)
|
||||
# Check for connection timeout and if it is greater than 0 then
|
||||
# set the environment variable PGCONNECT_TIMEOUT.
|
||||
timeout = manager.get_connection_param_value('connect_timeout')
|
||||
if timeout and int(timeout) > 0:
|
||||
env = dict()
|
||||
env['PGCONNECT_TIMEOUT'] = str(timeout)
|
||||
p.set_env_variables(server, env=env)
|
||||
else:
|
||||
p.set_env_variables(server)
|
||||
|
||||
p.set_env_variables(server)
|
||||
p.start()
|
||||
jid = p.id
|
||||
except Exception as e:
|
||||
|
||||
@@ -377,19 +377,9 @@ def create_restore_job(sid):
|
||||
*args,
|
||||
database=data['database']
|
||||
),
|
||||
cmd=utility, args=args
|
||||
cmd=utility, args=args, manager_obj=manager
|
||||
)
|
||||
manager.export_password_env(p.id)
|
||||
# Check for connection timeout and if it is greater than 0 then
|
||||
# set the environment variable PGCONNECT_TIMEOUT.
|
||||
timeout = manager.get_connection_param_value('connect_timeout')
|
||||
if timeout and int(timeout) > 0:
|
||||
env = dict()
|
||||
env['PGCONNECT_TIMEOUT'] = str(timeout)
|
||||
p.set_env_variables(server, env=env)
|
||||
else:
|
||||
p.set_env_variables(server)
|
||||
|
||||
p.set_env_variables(server)
|
||||
p.start()
|
||||
jid = p.id
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user