diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py index 850ff47a2..211458cca 100644 --- a/web/pgadmin/tools/backup/__init__.py +++ b/web/pgadmin/tools/backup/__init__.py @@ -376,30 +376,31 @@ def create_backup_objects_job(sid): def set_value(key, param, value): if key in data: - args.append(param) if value: - if value is True: + if value is True and param[key]: + args.append(param) args.append(param[key]) else: + args.append(param) args.append(value) set_param('verbose', '--verbose') set_param('dqoute', '--quote-all-identifiers') - + set_value('role', '--role', True) if data['format'] is not None: if data['format'] == 'custom': - args.extend(['--format', 'custom']) + args.extend(['--format=c']) set_param('blobs', '--blobs') set_value('ratio', '--compress', True) elif data['format'] == 'tar': - args.extend(['--format', 'tar']) + args.extend(['--format=t']) set_param('blobs', '--blobs') elif data['format'] == 'plain': - args.extend(['--format', 'plain']) + args.extend(['--format=p']) if 'only_data' in data and data['only_data']: args.append('--data-only') set_param('disable_trigger', '--disable-triggers') @@ -409,11 +410,11 @@ def create_backup_objects_job(sid): set_param('include_create_database', '--create') set_param('include_drop_database', '--clean') elif data['format'] == 'directory': - args.extend(['--format', 'directory']) + args.extend(['--format=d']) - set_param('pre_data', '--section pre-data') - set_param('data', '--section data') - set_param('post_data', '--section post-data') + set_param('pre_data', '--section=pre-data') + set_param('data', '--section=data') + set_param('post_data', '--section=post-data') set_param('dns_privilege', '--no-privileges') set_param('dns_tablespace', '--no-tablespaces') set_param('dns_unlogged_tbl_data', '--no-unlogged-table-data') @@ -423,6 +424,7 @@ def create_backup_objects_job(sid): set_param('with_oids', '--oids') set_param('use_set_session_auth', '--use-set-session-authorization') + set_value('encoding', '--encoding', True) set_value('no_of_jobs', '--jobs', True) for s in data['schemas']: diff --git a/web/pgadmin/tools/backup/templates/backup/js/backup.js b/web/pgadmin/tools/backup/templates/backup/js/backup.js index 8fff96008..7938a1d6f 100644 --- a/web/pgadmin/tools/backup/templates/backup/js/backup.js +++ b/web/pgadmin/tools/backup/templates/backup/js/backup.js @@ -102,7 +102,7 @@ TODO LIST FOR BACKUP: idAttribute: 'id', defaults: { file: undefined, - role: 'postgres', + role: undefined, format: 'custom', verbose: true, blobs: true, diff --git a/web/pgadmin/tools/restore/__init__.py b/web/pgadmin/tools/restore/__init__.py index 987bd396b..842394f40 100644 --- a/web/pgadmin/tools/restore/__init__.py +++ b/web/pgadmin/tools/restore/__init__.py @@ -221,27 +221,39 @@ def create_restore_job(sid): def set_value(key, param, value): if key in data: - args.append(param) if value: - if value is True: + if value is True and data[key]: + args.append(param) args.append(data[key]) else: + args.append(param) args.append(value) return True return False def set_multiple(key, param, with_schema=True): if key in data: - data[key] = json.loads(data[key]) if len(data[key]) > 0: if with_schema: - for s, o in data[key]: + # TODO:// This is temporary + # Once object tree is implemented then we will use + # list of tuples 'else' part + if isinstance(data[key], list): + s, t = data[key] args.extend([ param, driver.qtIdent( conn, s - ) + '.' + driver.qtIdent(conn, o) + ) + '.' + driver.qtIdent(conn, t) ]) + else: + for s, o in data[key]: + args.extend([ + param, + driver.qtIdent( + conn, s + ) + '.' + driver.qtIdent(conn, o) + ]) else: for o in data[key]: args.extend([param, o]) @@ -257,11 +269,11 @@ def create_restore_job(sid): set_value('database', '--dbname', True) if data['format'] == 'directory': - args.extend(['--format', 'directory']) + args.extend(['--format=d']) - set_value('pre_data', '--section', 'pre-data') - set_value('data', '--section', 'data') - set_value('post_data', '--section', 'post-data') + set_value('pre_data', '--section=pre-data', False) + set_value('data', '--section=data', False) + set_value('post_data', '--section=post-data', False) if not set_param('only_data', '--data-only'): set_param('dns_owner', '--no-owner') diff --git a/web/pgadmin/tools/restore/templates/restore/js/restore.js b/web/pgadmin/tools/restore/templates/restore/js/restore.js index 95fd80e23..7113bfd59 100644 --- a/web/pgadmin/tools/restore/templates/restore/js/restore.js +++ b/web/pgadmin/tools/restore/templates/restore/js/restore.js @@ -35,7 +35,7 @@ define([ defaults: { custom: false, file: undefined, - role: null, + role: undefined, format: 'Custom or tar', verbose: true, blobs: true,