Fix the issue in backup/restore while selecting section-> data option, it was throwing error.. Fixes #1219

This commit is contained in:
Murtuza Zabuawala 2016-06-17 14:01:30 +01:00 committed by Dave Page
parent b94b47f021
commit bc4703c5b7
4 changed files with 35 additions and 21 deletions

View File

@ -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']:

View File

@ -102,7 +102,7 @@ TODO LIST FOR BACKUP:
idAttribute: 'id',
defaults: {
file: undefined,
role: 'postgres',
role: undefined,
format: 'custom',
verbose: true,
blobs: true,

View File

@ -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')

View File

@ -35,7 +35,7 @@ define([
defaults: {
custom: false,
file: undefined,
role: null,
role: undefined,
format: 'Custom or tar',
verbose: true,
blobs: true,