3 /// Utility to dump tarball backup records to stdout.
7 Copyright (C) 2010, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program 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.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include <barry/barry.h>
23 #include <barry/barrybackup.h>
29 using namespace Barry
;
34 const char *Version
= Barry::Version(major
, minor
);
37 << "btardump - Command line parser for Barry backup files\n"
38 << " Copyright 2010, Net Direct Inc. (http://www.netdirect.ca/)\n"
39 << " Using: " << Version
<< "\n"
41 << " -d db Name of database to dump. Can be used multiple times\n"
42 << " to parse multiple databases at once. If not specified\n"
43 << " at all, all available databases from the backup are\n"
47 << " [files...] Backup file(s), created by btool or the backup GUI.\n"
51 int main(int argc
, char *argv
[])
55 vector
<string
> db_names
;
56 vector
<string
> backup_files
;
58 // process command line options
60 int cmd
= getopt(argc
, argv
, "d:h");
66 case 'd': // show dbname
67 db_names
.push_back(string(optarg
));
77 // grab all backup filenames
78 while( optind
< argc
) {
79 backup_files
.push_back(string(argv
[optind
++]));
82 if( backup_files
.size() == 0 ) {
91 // create the parser, and use stdout dump objects for output
92 AllRecordParser
parser(cout
,
93 new HexDumpParser(cout
),
94 new AllRecordDumpStore(cout
));
96 for( size_t i
= 0; i
< backup_files
.size(); i
++ ) {
98 cout
<< "Reading file: " << backup_files
[i
] << endl
;
100 Restore
builder(backup_files
[i
]);
102 // add desired database names
103 for( size_t j
= 0; j
< db_names
.size(); j
++ ) {
104 builder
.AddDB(db_names
[i
]);
107 // create the pipe to connect builder to parser and
110 pipe
.PumpFile(parser
);
114 catch( exception
&e
) {
115 cerr
<< e
.what() << endl
;