1 | /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
2 | // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: |
3 | #ident "$Id$" |
4 | /*====== |
5 | This file is part of PerconaFT. |
6 | |
7 | |
8 | Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. |
9 | |
10 | PerconaFT is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License, version 2, |
12 | as published by the Free Software Foundation. |
13 | |
14 | PerconaFT is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU General Public License |
20 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
21 | |
22 | ---------------------------------------- |
23 | |
24 | PerconaFT is free software: you can redistribute it and/or modify |
25 | it under the terms of the GNU Affero General Public License, version 3, |
26 | as published by the Free Software Foundation. |
27 | |
28 | PerconaFT is distributed in the hope that it will be useful, |
29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31 | GNU Affero General Public License for more details. |
32 | |
33 | You should have received a copy of the GNU Affero General Public License |
34 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
35 | ======= */ |
36 | |
37 | #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." |
38 | |
39 | /* Recover an env. The logs are in argv[1]. The new database is created in the cwd. */ |
40 | |
41 | // Test: |
42 | // cd ../src/tests/tmpdir |
43 | // ../../../ft/recover ../dir.test_log2.c.tdb |
44 | |
45 | #include "ft/ft-ops.h" |
46 | #include "ft/logger/recover.h" |
47 | |
48 | static int recovery_main(int argc, const char *const argv[]); |
49 | |
50 | int main(int argc, const char *const argv[]) { |
51 | int r = toku_ft_layer_init(); |
52 | assert(r == 0); |
53 | r = recovery_main(argc, argv); |
54 | toku_ft_layer_destroy(); |
55 | return r; |
56 | } |
57 | |
58 | int recovery_main (int argc, const char *const argv[]) { |
59 | const char *data_dir, *log_dir; |
60 | if (argc==3) { |
61 | data_dir = argv[1]; |
62 | log_dir = argv[2]; |
63 | } else if (argc==2) { |
64 | data_dir = log_dir = argv[1]; |
65 | } else { |
66 | printf("Usage: %s <datadir> [ <logdir> ]\n" , argv[0]); |
67 | return(1); |
68 | } |
69 | |
70 | int r = tokuft_recover(nullptr, |
71 | nullptr, |
72 | nullptr, |
73 | nullptr, |
74 | data_dir, log_dir, nullptr, nullptr, nullptr, nullptr, 0); |
75 | if (r!=0) { |
76 | fprintf(stderr, "Recovery failed\n" ); |
77 | return(1); |
78 | } |
79 | return 0; |
80 | } |
81 | |