本文整理汇总了Python中barman.recovery_executor.RecoveryExecutor.recover方法的典型用法代码示例。如果您正苦于以下问题:Python RecoveryExecutor.recover方法的具体用法?Python RecoveryExecutor.recover怎么用?Python RecoveryExecutor.recover使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类barman.recovery_executor.RecoveryExecutor
的用法示例。
在下文中一共展示了RecoveryExecutor.recover方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recover
# 需要导入模块: from barman.recovery_executor import RecoveryExecutor [as 别名]
# 或者: from barman.recovery_executor.RecoveryExecutor import recover [as 别名]
def recover(self, backup_info, dest, tablespaces=None, target_tli=None,
target_time=None, target_xid=None, target_name=None,
exclusive=False, remote_command=None):
"""
Performs a recovery of a backup
:param barman.infofile.BackupInfo backup_info: the backup to recover
:param str dest: the destination directory
:param dict[str,str]|None tablespaces: a tablespace name -> location map
(for relocation)
:param str|None target_tli: the target timeline
:param str|None target_time: the target time
:param str|None target_xid: the target xid
:param str|None target_name: the target name created previously with
pg_create_restore_point() function call
:param bool exclusive: whether the recovery is exclusive or not
:param str|None remote_command: default None. The remote command to recover
the base backup, in case of remote backup.
"""
# Archive every WAL files in the incoming directory of the server
self.server.archive_wal(verbose=False)
# Delegate the recovery operation to a RecoveryExecutor object
executor = RecoveryExecutor(self)
recovery_info = executor.recover(backup_info,
dest, tablespaces,
target_tli, target_time,
target_xid, target_name,
exclusive, remote_command)
# Output recovery results
output.result('recovery', recovery_info['results'])
示例2: test_recovery
# 需要导入模块: from barman.recovery_executor import RecoveryExecutor [as 别名]
# 或者: from barman.recovery_executor.RecoveryExecutor import recover [as 别名]
def test_recovery(self, remote_cmd_mock, rsync_pg_mock, tmpdir):
"""
Test the execution of a recovery
"""
# Prepare basic directory/files structure
dest = tmpdir.mkdir('destination')
base = tmpdir.mkdir('base')
wals = tmpdir.mkdir('wals')
backup_info = testing_helpers.build_test_backup_info(tablespaces=[])
backup_info.config.basebackups_directory = base.strpath
backup_info.config.wals_directory = wals.strpath
backup_info.version = 90400
datadir = base.mkdir(backup_info.backup_id).mkdir('data')
backup_info.pgdata = datadir.strpath
postgresql_conf_local = datadir.join('postgresql.conf')
postgresql_auto_local = datadir.join('postgresql.auto.conf')
postgresql_conf_local.write('archive_command = something\n'
'data_directory = something')
postgresql_auto_local.write('archive_command = something\n'
'data_directory = something')
shutil.copy2(postgresql_conf_local.strpath, dest.strpath)
shutil.copy2(postgresql_auto_local.strpath, dest.strpath)
# Build an executor
server = testing_helpers.build_real_server(
global_conf={
"barman_lock_directory": tmpdir.mkdir('lock').strpath
},
main_conf={
"wals_directory": wals.strpath
})
executor = RecoveryExecutor(server.backup_manager)
# test local recovery
rec_info = executor.recover(backup_info, dest.strpath, None, None,
None, None, None, True, None)
# remove not usefull keys from the result
del rec_info['cmd']
sys_tempdir = rec_info['tempdir']
assert rec_info == {
'rsync': None,
'tempdir': sys_tempdir,
'wal_dest': dest.join('pg_xlog').strpath,
'recovery_dest': 'local',
'destination_path': dest.strpath,
'temporary_configuration_files': [
dest.join('postgresql.conf').strpath,
dest.join('postgresql.auto.conf').strpath],
'results': {
'delete_barman_xlog': False,
'get_wal': False,
'changes': [
Assertion._make([
'postgresql.conf',
0,
'archive_command',
'false']),
Assertion._make([
'postgresql.auto.conf',
0,
'archive_command',
'false'])],
'warnings': [
Assertion._make([
'postgresql.conf',
2,
'data_directory',
'something']),
Assertion._make([
'postgresql.auto.conf',
2,
'data_directory',
'something'])]},
'target_epoch': None,
'configuration_files': [
'postgresql.conf',
'postgresql.auto.conf'],
'target_datetime': None,
'safe_horizon': None,
'is_pitr': False,
'get_wal': False,
}
# test remote recovery
rec_info = executor.recover(backup_info, dest.strpath, {}, None, None,
None, None, True, "[email protected]")
# remove not usefull keys from the result
del rec_info['cmd']
del rec_info['rsync']
sys_tempdir = rec_info['tempdir']
assert rec_info == {
'tempdir': sys_tempdir,
'wal_dest': dest.join('pg_xlog').strpath,
'recovery_dest': 'remote',
'destination_path': dest.strpath,
'temporary_configuration_files': [
os.path.join(sys_tempdir, 'postgresql.conf'),
os.path.join(sys_tempdir, 'postgresql.auto.conf')],
'results': {
'delete_barman_xlog': False,
'get_wal': False,
'changes': [
Assertion._make([
#.........这里部分代码省略.........
示例3: test_recovery
# 需要导入模块: from barman.recovery_executor import RecoveryExecutor [as 别名]
# 或者: from barman.recovery_executor.RecoveryExecutor import recover [as 别名]
def test_recovery(self, remote_cmd_mock, rsync_pg_mock, copy_controller_mock, tmpdir):
"""
Test the execution of a recovery
"""
# Prepare basic directory/files structure
dest = tmpdir.mkdir("destination")
base = tmpdir.mkdir("base")
wals = tmpdir.mkdir("wals")
backup_info = testing_helpers.build_test_backup_info(tablespaces=[])
backup_info.config.basebackups_directory = base.strpath
backup_info.config.wals_directory = wals.strpath
backup_info.version = 90400
datadir = base.mkdir(backup_info.backup_id).mkdir("data")
backup_info.pgdata = datadir.strpath
postgresql_conf_local = datadir.join("postgresql.conf")
postgresql_auto_local = datadir.join("postgresql.auto.conf")
postgresql_conf_local.write("archive_command = something\n" "data_directory = something")
postgresql_auto_local.write("archive_command = something\n" "data_directory = something")
shutil.copy2(postgresql_conf_local.strpath, dest.strpath)
shutil.copy2(postgresql_auto_local.strpath, dest.strpath)
# Avoid triggering warning for missing config files
datadir.ensure("pg_hba.conf")
datadir.ensure("pg_ident.conf")
# Build an executor
server = testing_helpers.build_real_server(
global_conf={"barman_lock_directory": tmpdir.mkdir("lock").strpath},
main_conf={"wals_directory": wals.strpath},
)
executor = RecoveryExecutor(server.backup_manager)
# test local recovery
rec_info = executor.recover(backup_info, dest.strpath, None, None, None, None, None, True, None)
# remove not usefull keys from the result
del rec_info["cmd"]
sys_tempdir = rec_info["tempdir"]
assert rec_info == {
"rsync": None,
"tempdir": sys_tempdir,
"wal_dest": dest.join("pg_xlog").strpath,
"recovery_dest": "local",
"destination_path": dest.strpath,
"temporary_configuration_files": [
dest.join("postgresql.conf").strpath,
dest.join("postgresql.auto.conf").strpath,
],
"results": {
"delete_barman_xlog": False,
"get_wal": False,
"changes": [
Assertion._make(["postgresql.conf", 0, "archive_command", "false"]),
Assertion._make(["postgresql.auto.conf", 0, "archive_command", "false"]),
],
"missing_files": [],
"warnings": [
Assertion._make(["postgresql.conf", 2, "data_directory", "something"]),
Assertion._make(["postgresql.auto.conf", 2, "data_directory", "something"]),
],
},
"target_epoch": None,
"configuration_files": ["postgresql.conf", "postgresql.auto.conf"],
"target_datetime": None,
"safe_horizon": None,
"is_pitr": False,
"get_wal": False,
}
# test remote recovery
rec_info = executor.recover(backup_info, dest.strpath, {}, None, None, None, None, True, "[email protected]")
# remove not useful keys from the result
del rec_info["cmd"]
del rec_info["rsync"]
sys_tempdir = rec_info["tempdir"]
assert rec_info == {
"tempdir": sys_tempdir,
"wal_dest": dest.join("pg_xlog").strpath,
"recovery_dest": "remote",
"destination_path": dest.strpath,
"temporary_configuration_files": [
os.path.join(sys_tempdir, "postgresql.conf"),
os.path.join(sys_tempdir, "postgresql.auto.conf"),
],
"results": {
"delete_barman_xlog": False,
"get_wal": False,
"changes": [
Assertion._make(["postgresql.conf", 0, "archive_command", "false"]),
Assertion._make(["postgresql.auto.conf", 0, "archive_command", "false"]),
],
"missing_files": [],
"warnings": [
Assertion._make(["postgresql.conf", 2, "data_directory", "something"]),
Assertion._make(["postgresql.auto.conf", 2, "data_directory", "something"]),
],
},
"target_epoch": None,
"configuration_files": ["postgresql.conf", "postgresql.auto.conf"],
"target_datetime": None,
"safe_horizon": None,
"is_pitr": False,
"get_wal": False,
}
# test failed rsync
#.........这里部分代码省略.........