提交 cf25f22b 编写于 作者: S Stephen Wu 提交者: GitHub

Allow incremental backup for ddboost to work across multiple dates. (#1328)

When running backup with ddboost, we now use dump timestamp instead of current timestamp as the parent directory.  This fixes a bug where the dump fails if the report and cdatabase files are generated on different days (e.g. if the dump is kicked off just before midnight).

Authors: Stephen Wu and Jamie McAtamney
上级 42bdb6ef
......@@ -292,7 +292,7 @@ def convert_report_filename_to_cdatabase_filename(context, report_file):
ddboost_parent_dir = None
if context.ddboost:
ddboost_parent_dir = context.get_backup_dir(directory='')
ddboost_parent_dir = context.get_backup_dir(timestamp=timestamp, directory='')
return context.generate_filename("cdatabase", timestamp=timestamp, directory=ddboost_parent_dir)
def get_lines_from_dd_file(filename, ddboost_storage_unit):
......
......@@ -230,6 +230,22 @@ class BackupUtilsTestCase(unittest.TestCase):
cdatabase_file = convert_report_filename_to_cdatabase_filename(self.context, report_file)
self.assertEquals(expected_output, cdatabase_file)
def test_convert_report_filename_to_cdatabase_filename_with_prefix_default(self):
report_file = '/data/db_dumps/20160101/bar_gp_dump_20160101010101.rpt'
expected_output = '/data/db_dumps/20160101/bar_gp_cdatabase_1_1_20160101010101'
self.context.dump_prefix = 'bar_'
cdatabase_file = convert_report_filename_to_cdatabase_filename(self.context, report_file)
self.assertEquals(expected_output, cdatabase_file)
def test_convert_report_filename_to_cdatabase_filename_ddboost_with_earlier_date(self):
# use the date from the file to calculate the directory,
# not the current date
report_file = '/data/db_dumps/20080101/gp_dump_20080101010101.rpt'
expected_output = '/db_dumps/20080101/gp_cdatabase_1_1_20080101010101' #path in data domain
self.context.ddboost = True
cdatabase_file = convert_report_filename_to_cdatabase_filename(self.context, report_file)
self.assertEquals(expected_output, cdatabase_file)
@patch('gppylib.operations.backup_utils.get_lines_from_file', return_value=['--', '-- Database creation', '--', '', "CREATE DATABASE bkdb WITH TEMPLATE = template0 ENCODING = 'UTF8' OWNER = dcddev;"])
def test_check_cdatabase_exists_default(self, mock):
self.context.dump_database = 'bkdb'
......@@ -856,13 +872,6 @@ class BackupUtilsTestCase(unittest.TestCase):
with self.assertRaisesRegexp(Exception, 'No full backup found for incremental'):
get_latest_full_dump_timestamp(self.context)
def test_convert_report_filename_to_cdatabase_filename_with_prefix_default(self):
report_file = '/data/db_dumps/20160101/bar_gp_dump_20160101010101.rpt'
expected_output = '/data/db_dumps/20160101/bar_gp_cdatabase_1_1_20160101010101'
self.context.dump_prefix = 'bar_'
cdatabase_file = convert_report_filename_to_cdatabase_filename(self.context, report_file)
self.assertEquals(expected_output, cdatabase_file)
@patch('gppylib.operations.backup_utils.Command.run')
def test_backup_file_with_nbu_default(self, mock1):
backup_file_with_nbu(self.context, path=self.netbackup_filepath)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册