]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/tools/dump/rocksdb_dump.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / tools / dump / rocksdb_dump.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5
6 #if !(defined GFLAGS) || defined(ROCKSDB_LITE)
7
8 #include <cstdio>
9 int main() {
10 #ifndef GFLAGS
11 fprintf(stderr, "Please install gflags to run rocksdb tools\n");
12 #endif
13 #ifdef ROCKSDB_LITE
14 fprintf(stderr, "DbDumpTool is not supported in ROCKSDB_LITE\n");
15 #endif
16 return 1;
17 }
18
19 #else
20
21 #include "rocksdb/convenience.h"
22 #include "rocksdb/db_dump_tool.h"
23 #include "util/gflags_compat.h"
24
25 DEFINE_string(db_path, "", "Path to the db that will be dumped");
26 DEFINE_string(dump_location, "", "Path to where the dump file location");
27 DEFINE_bool(anonymous, false,
28 "Remove information like db path, creation time from dumped file");
29 DEFINE_string(db_options, "",
30 "Options string used to open the database that will be dumped");
31
32 int main(int argc, char** argv) {
33 GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
34
35 if (FLAGS_db_path == "" || FLAGS_dump_location == "") {
36 fprintf(stderr, "Please set --db_path and --dump_location\n");
37 return 1;
38 }
39
40 rocksdb::DumpOptions dump_options;
41 dump_options.db_path = FLAGS_db_path;
42 dump_options.dump_location = FLAGS_dump_location;
43 dump_options.anonymous = FLAGS_anonymous;
44
45 rocksdb::Options db_options;
46 if (FLAGS_db_options != "") {
47 rocksdb::Options parsed_options;
48 rocksdb::Status s = rocksdb::GetOptionsFromString(
49 db_options, FLAGS_db_options, &parsed_options);
50 if (!s.ok()) {
51 fprintf(stderr, "Cannot parse provided db_options\n");
52 return 1;
53 }
54 db_options = parsed_options;
55 }
56
57 rocksdb::DbDumpTool tool;
58 if (!tool.Run(dump_options, db_options)) {
59 return 1;
60 }
61 return 0;
62 }
63 #endif // !(defined GFLAGS) || defined(ROCKSDB_LITE)