1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
6 #if !(defined GFLAGS) || defined(ROCKSDB_LITE)
11 fprintf(stderr
, "Please install gflags to run rocksdb tools\n");
14 fprintf(stderr
, "DbUndumpTool is not supported in ROCKSDB_LITE\n");
21 #include <gflags/gflags.h>
22 #include "rocksdb/convenience.h"
23 #include "rocksdb/db_dump_tool.h"
25 DEFINE_string(dump_location
, "", "Path to the dump file that will be loaded");
26 DEFINE_string(db_path
, "", "Path to the db that we will undump the file into");
27 DEFINE_bool(compact
, false, "Compact the db after loading the dumped file");
28 DEFINE_string(db_options
, "",
29 "Options string used to open the database that will be loaded");
31 int main(int argc
, char **argv
) {
32 GFLAGS::ParseCommandLineFlags(&argc
, &argv
, true);
34 if (FLAGS_db_path
== "" || FLAGS_dump_location
== "") {
35 fprintf(stderr
, "Please set --db_path and --dump_location\n");
39 rocksdb::UndumpOptions undump_options
;
40 undump_options
.db_path
= FLAGS_db_path
;
41 undump_options
.dump_location
= FLAGS_dump_location
;
42 undump_options
.compact_db
= FLAGS_compact
;
44 rocksdb::Options db_options
;
45 if (FLAGS_db_options
!= "") {
46 rocksdb::Options parsed_options
;
47 rocksdb::Status s
= rocksdb::GetOptionsFromString(
48 db_options
, FLAGS_db_options
, &parsed_options
);
50 fprintf(stderr
, "Cannot parse provided db_options\n");
53 db_options
= parsed_options
;
56 rocksdb::DbUndumpTool tool
;
57 if (!tool
.Run(undump_options
, db_options
)) {
62 #endif // !(defined GFLAGS) || defined(ROCKSDB_LITE)