From 82faa377a8276faedfaeeebfbec6da6e2bc68540 Mon Sep 17 00:00:00 2001 From: Marko Kevac Date: Mon, 9 Feb 2015 19:34:50 +0300 Subject: [PATCH] added simple example for db restore from backup --- examples/c_simple_example.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/c_simple_example.c b/examples/c_simple_example.c index fd79a6968..c152b7da1 100644 --- a/examples/c_simple_example.c +++ b/examples/c_simple_example.c @@ -51,6 +51,17 @@ int main(int argc, char **argv) { rocksdb_backup_engine_create_new_backup(be, db, &err); assert(!err); + rocksdb_close(db); + + // If something is wrong, you might want to restore data from last backup + rocksdb_restore_options_t *restore_options = rocksdb_restore_options_create(); + rocksdb_backup_engine_restore_db_from_latest_backup(be, DBPath, DBPath, restore_options, &err); + assert(!err); + rocksdb_restore_options_destroy(restore_options); + + db = rocksdb_open(options, DBPath, &err); + assert(!err); + // cleanup rocksdb_writeoptions_destroy(writeoptions); rocksdb_readoptions_destroy(readoptions);