2013-04-17 00:00:59 -04:00
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
2013-04-16 23:57:48 -04:00
# ident "$Id$"
2013-04-17 00:00:59 -04:00
# ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
2013-04-16 23:57:48 -04:00
# ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11 / 760379 and to the patents and / or patent applications resulting from it."
2008-03-12 19:40:38 +00:00
/* Recover an env. The logs are in argv[1]. The new database is created in the cwd. */
// Test:
// cd ../src/tests/tmpdir
2013-04-17 00:00:35 -04:00
// ../../../ft/recover ../dir.test_log2.c.tdb
2008-03-12 19:40:38 +00:00
2013-04-16 23:57:20 -04:00
# include "includes.h"
2008-03-12 19:40:38 +00:00
2013-04-16 23:59:01 -04:00
static int recovery_main ( int argc , const char * const argv [ ] ) ;
2013-04-16 23:57:45 -04:00
int
2013-04-16 23:59:01 -04:00
main ( int argc , const char * const argv [ ] ) {
2013-04-16 23:59:23 -04:00
{
2013-04-17 00:00:43 -04:00
int rr = toku_ft_layer_init ( ) ;
2013-04-16 23:59:23 -04:00
assert ( rr = = 0 ) ;
}
2013-04-16 23:57:45 -04:00
int r = recovery_main ( argc , argv ) ;
2013-04-17 00:00:43 -04:00
toku_ft_layer_destroy ( ) ;
2013-04-16 23:57:45 -04:00
return r ;
}
2013-04-16 23:59:01 -04:00
int recovery_main ( int argc , const char * const argv [ ] ) {
2013-04-16 23:57:44 -04:00
const char * data_dir , * log_dir ;
if ( argc = = 3 ) {
data_dir = argv [ 1 ] ;
log_dir = argv [ 2 ] ;
} else if ( argc = = 2 ) {
data_dir = log_dir = argv [ 1 ] ;
} else {
printf ( " Usage: %s <datadir> [ <logdir> ] \n " , argv [ 0 ] ) ;
2013-04-16 23:57:45 -04:00
return ( 1 ) ;
2013-04-16 23:57:44 -04:00
}
2008-03-12 19:40:38 +00:00
2013-04-17 00:00:14 -04:00
int r = tokudb_recover ( NULL ,
NULL_prepared_txn_callback ,
NULL_keep_cachetable_callback ,
NULL_logger ,
data_dir , log_dir , NULL , NULL , NULL , NULL , 0 ) ;
2008-03-14 19:14:31 +00:00
if ( r ! = 0 ) {
fprintf ( stderr , " Recovery failed \n " ) ;
2013-04-16 23:57:45 -04:00
return ( 1 ) ;
2008-03-12 19:40:38 +00:00
}
return 0 ;
}