]>
git.proxmox.com Git - ceph.git/blob - 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).
6 #if !(defined GFLAGS) || defined(ROCKSDB_LITE)
11 fprintf(stderr
, "Please install gflags to run rocksdb tools\n");
14 fprintf(stderr
, "DbDumpTool is not supported in ROCKSDB_LITE\n");
21 #include "rocksdb/convenience.h"
22 #include "rocksdb/db_dump_tool.h"
23 #include "util/gflags_compat.h"
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");
32 int main(int argc
, char** argv
) {
33 GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc
, &argv
, true);
35 if (FLAGS_db_path
== "" || FLAGS_dump_location
== "") {
36 fprintf(stderr
, "Please set --db_path and --dump_location\n");
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
;
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
);
51 fprintf(stderr
, "Cannot parse provided db_options\n");
54 db_options
= parsed_options
;
57 rocksdb::DbDumpTool tool
;
58 if (!tool
.Run(dump_options
, db_options
)) {
63 #endif // !(defined GFLAGS) || defined(ROCKSDB_LITE)