From 01e0e0ead99ae23ab060b2307b3b0d3c9c231893 Mon Sep 17 00:00:00 2001 From: LoLolobster <949673574@qq.com> Date: Tue, 15 Oct 2024 14:13:48 +0000 Subject: [PATCH] [CP] [CP] fix ob_admin dump_backup check_exist & fix can not dump tenant_backup_set_infos.obbak --- .../ob_admin_dump_backup_data_executor.cpp | 31 ++++++++++++++++--- .../ob_admin_dump_backup_data_executor.h | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.cpp b/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.cpp index 06b373f4b5..e478232fe7 100644 --- a/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.cpp +++ b/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.cpp @@ -600,8 +600,10 @@ int ObAdminDumpBackupDataExecutor::execute(int argc, char *argv[]) STORAGE_LOG(WARN, "fail to check is table list dir", K(ret)); } if (OB_FAIL(ret)) { - } else if (is_table_list_dir && OB_FAIL(handle_print_table_list_())) { - STORAGE_LOG(WARN, "fail to handle print table list", K(ret), K_(backup_path)); + } else if (is_table_list_dir) { + if (OB_FAIL(handle_print_table_list_())) { + STORAGE_LOG(WARN, "fail to handle print table list", K(ret), K_(backup_path)); + } } else if (OB_FAIL(check_file_exist_(backup_path_, storage_info_))) { STORAGE_LOG(WARN, "failed to check exist", K(ret), K_(backup_path), K_(storage_info)); } else if (OB_FAIL(get_backup_file_type_())) { @@ -618,7 +620,7 @@ int ObAdminDumpBackupDataExecutor::parse_cmd_(int argc, char *argv[]) int ret = OB_SUCCESS; int opt = 0; int index = -1; - const char *opt_str = "h:d:s:o:l:qc:e:"; + const char *opt_str = "h:d:s:o:l:qce:"; struct option longopts[] = {{"help", 0, NULL, 'h'}, {"backup_path", 1, NULL, 'd'}, {"storage_info", 1, NULL, 's'}, @@ -1773,7 +1775,7 @@ int ObAdminDumpBackupDataExecutor::print_tenant_backup_set_infos_() } else if (OB_FAIL(ObAdminDumpBackupDataUtil::read_backup_info_file(ObString(backup_path_), ObString(storage_info_), file_desc))) { STORAGE_LOG(WARN, "fail to read archive piece info file", K(ret), K(backup_path_), K(storage_info_)); } else if(!file_desc.backup_set_infos_.empty()) { - if (OB_FAIL(dump_tenant_backup_set_infos_(file_desc.backup_set_infos_))) { + if (OB_FAIL(dump_tenant_backup_set_infos_file_(file_desc.backup_set_infos_))) { STORAGE_LOG(WARN, "fail to dump archive piece info file", K(ret), K(file_desc)); } } @@ -2533,6 +2535,27 @@ int ObAdminDumpBackupDataExecutor::dump_tenant_backup_set_infos_(const ObIArray< return ret; } +int ObAdminDumpBackupDataExecutor::dump_tenant_backup_set_infos_file_(const ObIArray &backup_set_infos) +{ + int ret = OB_SUCCESS; + if (share::ObBackupFileType::BACKUP_TENANT_SET_INFOS == file_type_) { + PrintHelper::print_dump_title("tenant backup set infos"); + ARRAY_FOREACH_X(backup_set_infos, i , cnt, OB_SUCC(ret)) { + const share::ObBackupSetFileDesc &backup_set_desc = backup_set_infos.at(i); + char buf[OB_MAX_CHAR_LEN] = { 0 }; + char str_buf[OB_MAX_TEXT_LENGTH] = { 0 }; + if (OB_FAIL(databuff_printf(buf, OB_MAX_CHAR_LEN, "%ld", i+1))) { + STORAGE_LOG(WARN, "fail to printf buf", K(ret), K(i)); + } else if (OB_FALSE_IT(backup_set_desc.to_string(str_buf, OB_MAX_TEXT_LENGTH))) { + } else { + PrintHelper::print_dump_line(buf, str_buf); + } + } + PrintHelper::print_end_line(); + } + return ret; +} + int ObAdminDumpBackupDataExecutor::dump_backup_ls_meta_infos_file_(const storage::ObBackupLSMetaInfosDesc &ls_meta_infos) { int ret = OB_SUCCESS; diff --git a/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.h b/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.h index 6fadec6369..1d9f054e9b 100644 --- a/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.h +++ b/tools/ob_admin/backup_tool/ob_admin_dump_backup_data_executor.h @@ -173,6 +173,7 @@ private: int dump_tenant_diagnose_info_(const storage::ObExternTenantDiagnoseInfoDesc &diagnose_info); int dump_backup_set_info(const share::ObBackupSetFileDesc &backup_set_info); int dump_tenant_backup_set_infos_(const ObIArray &backup_set_infos); + int dump_tenant_backup_set_infos_file_(const ObIArray &backup_set_infos); int dump_backup_ls_meta_infos_file_(const storage::ObBackupLSMetaInfosDesc &ls_meta_infos); int dump_archive_round_start_file_(const share::ObRoundStartDesc &round_start_file); int dump_archive_round_end_file_(const share::ObRoundEndDesc round_end_file);