rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rvm.cc
Go to the documentation of this file.
1 #include "config.h"
2 
3 #include <iostream>
4 
5 #include "asserts.h"
6 #include "error.h"
7 #include "help.h"
8 #include "rconfig.h"
9 #include "archiver.h"
10 #include "cataloger.h"
11 #include "reporter.h"
12 #include "estat.h"
13 
14 /** \mainpage Rsync Vault Manager
15 
16 Rvm is an archive manager that uses rsync to create and maintain a list of
17 archives that span one or more vaults. A vault is a directory on a logical
18 partition that holds one or more archives. An archive is a time-sensitive
19 subdirectory in a vault that holds the files and directories backed up from
20 one or more archive jobs. Files that are identical to files in older archives
21 may be optionally replaced with hard links to the older version to save space.
22 
23 */
24 int main(int argc, char const * argv[])
25 {
26  try {
27  /*
28  * Parse command line arguments, read configuration files, and perform
29  * sanity checks on the configuration settings.
30  */
31  config.init(argc, argv);
32  }
33  catch(error e) {
34  std::cerr << e << std::endl;
36  }
37  catch(...) {
38  std::cerr << err_unknown << std::endl;
40  }
41 
42  if ((exit_manager.value() == exitstat::ok) && (config.initialized())) {
43  try {
44  /*
45  * Perform the requested action.
46  */
48  print_help();
49  }
51  print_version();
52  }
54  timer t;
55 
56  t.start();
57 
58  logger.init();
59  vaulter.init();
60  reporter.init();
61  archiver.init();
62  cataloger.init();
63  reporter.init();
64  archiver.archive();
66 
67  t.stop();
68 
70 
73  }
75  logger.init();
76  cataloger.init();
78  }
80  // return(0);
81  }
82  else {
83  // This should never happen
84  throw(INTERNAL_ERROR(0,"Unknown action"));
85  }
86  }
87  catch(error e) {
88  std::cerr << e << std::endl;
89  logger.write(e.str());
90  }
91  catch(...) {
92  std::cerr << err_unknown << std::endl;
93  logger.write(err_unknown.str());
95  }
96  }
97 
99  return(1);
101  return(2);
103  return(3);
105  return(4);
106  return(0);
107 }
108 
void init(int argc, char const *argv[])
Initialize the configuration manager from rvm's command line options.
Definition: rconfig.cc:1218
log_manager logger
The global log manager.
Definition: logger.cc:138
void init(void)
Initialize the vault manager.
Definition: vaulter.cc:40
void catalog(void)
Create or update the catalog.
Definition: cataloger.cc:77
void print_help(void)
Definition: help.cc:10
void write(const std::string &a_str, const uint16 a_indention=0, const configuration_manager::logging_type a_logging_level=configuration_manager::logging_manager, const pid_t a_pid=pid())
Write a string to the log file.
Definition: logger.cc:96
const action_type action(void) const
Return the action rvm is to take.
Definition: rconfig.cc:1466
archive_manager archiver
The global archive manager.
Definition: archiver.cc:1536
#define err_unknown
Definition: error.h:114
void set_total_time(const timer &a_class)
Report the overall RVM time.
Definition: reporter.cc:960
void assign(value_type a_value)
Definition: estat.cc:15
report_manager reporter
The global report manager.
Definition: reporter.cc:1124
void file_report(void)
Save report to a file.
Definition: reporter.cc:998
void start(void)
Start (or restart) the timer.
Definition: timer.cc:137
An error class.
Definition: error.h:72
const bool initialized(void) const
Return the initialized state of the configuration manager.
Definition: rconfig.cc:1459
catalog_manager cataloger
The global catalog manager.
Definition: cataloger.cc:135
int main(int argc, char const *argv[])
Definition: rvm.cc:24
void init(void)
Initialize the log manager.
Definition: logger.cc:42
#define INTERNAL_ERROR(e, s)
Definition: error.h:123
configuration_manager config
The global configuration manager instance.
Definition: rconfig.cc:3364
exitstat exit_manager
Definition: estat.cc:25
void init(void)
Initialize the catalog manager.
Definition: cataloger.cc:36
void init(void)
Initialize the archive manager.
Definition: archiver.cc:1078
void print_report(void)
Print report to standard output.
Definition: reporter.cc:981
void archive(void)
Archive jobs.
Definition: archiver.cc:1235
void stop(void)
Stop the timer.
Definition: timer.cc:143
void print_version(void)
Definition: help.cc:47
const std::string str(const std::string a_prefix="") const
Definition: error.cc:304
void init(void)
Initialize.
Definition: reporter.cc:937
Used as a stopwatch.
Definition: timer.h:29
vault_manager vaulter
The global vault manager.
Definition: vaulter.cc:772
const value_type value(void) const
Definition: estat.cc:20