backup [inmem] [backup_filename]
| 1528 | |
| 1529 | // backup [inmem] [backup_filename] |
| 1530 | CliStatus MetaBackUpOp(Client* client, int32_t argc, std::string* argv, ErrorCode* err) { |
| 1531 | std::string filename; |
| 1532 | if ((argc == 3 || argc == 4) && argv[2] == "inmem") { |
| 1533 | if (argc == 3) { |
| 1534 | filename = "inmem_meta.bak_" + get_curtime_str(); |
| 1535 | } else { |
| 1536 | filename = argv[3] + "_" + get_curtime_str(); |
| 1537 | } |
| 1538 | std::shared_ptr<tera::ClientImpl> client_impl( |
| 1539 | (static_cast<ClientWrapper*>(client))->GetClientImpl()); |
| 1540 | std::vector<std::string> arg_list; |
| 1541 | arg_list.push_back("backup"); |
| 1542 | arg_list.push_back(filename); |
| 1543 | if (!client->CmdCtrl("meta", arg_list, NULL, NULL, err)) { |
| 1544 | LOG(ERROR) << "fail to backup meta"; |
| 1545 | return CliStatus::kError; |
| 1546 | } |
| 1547 | } else if (argc == 2 || argc == 3) { |
| 1548 | scoped_ptr<tera::sdk::ClusterFinder> finder(tera::sdk::NewClusterFinder()); |
| 1549 | const std::string meta_server = finder->RootTableAddr(); |
| 1550 | if (argc == 2) { |
| 1551 | filename = "meta.bak_" + get_curtime_str(); |
| 1552 | } else { |
| 1553 | filename = argv[2] + "_" + get_curtime_str(); |
| 1554 | } |
| 1555 | common::ThreadPool thread_pool(1); |
| 1556 | std::string start_key(""); |
| 1557 | std::string end_key(""); |
| 1558 | MetaInternalOp(meta_server, &thread_pool, "backup", start_key, end_key, filename); |
| 1559 | } else { |
| 1560 | PrintCmdHelpInfo(argv[1]); |
| 1561 | } |
| 1562 | return CliStatus::kOk; |
| 1563 | } |
| 1564 | |
| 1565 | // healthcheck [inmem] [start_key] [end_key] |
| 1566 | CliStatus MetaHealthCheckOp(Client* client, int32_t argc, std::string* argv, ErrorCode* err) { |
nothing calls this directly
no test coverage detected