rvm.cc

Go to the documentation of this file.
00001 #include "config.h"
00002 
00003 #include <iostream>
00004 
00005 #include "asserts.h"
00006 #include "error.h"
00007 #include "help.h"
00008 #include "rconfig.h"
00009 #include "archiver.h"
00010 #include "cataloger.h"
00011 #include "reporter.h"
00012 #include "estat.h"
00013 
00014 /** \mainpage Rsync Vault Manager
00015 
00016 Rvm is an archive manager that uses rsync to create and maintain a list of
00017 archives that span one or more vaults.  A vault is a directory on a logical
00018 partition that holds one or more archives.  An archive is a time-sensitive
00019 subdirectory in a vault that holds the files and directories backed up from
00020 one or more archive jobs.  Files that are identical to files in older archives
00021 may be optionally replaced with hard links to the older version to save space.
00022 
00023 */
00024 int main(int argc, char* argv[])
00025 {
00026         try {
00027                 /*
00028                  * Parse command line arguments, read configuration files, and perform
00029                  * sanity checks on the configuration settings.
00030                  */
00031                 config.init(argc, argv);
00032         }
00033         catch(error e) {
00034                 std::cerr << e << std::endl;
00035                 exit_manager.assign(exitstat::config_error);
00036         }
00037         catch(...) {
00038                 std::cerr << err_unknown << std::endl;
00039                 exit_manager.assign(exitstat::other_error);
00040         }
00041 
00042         if (config.initialized()) {
00043                 try {
00044                         /*
00045                          * Perform the requested action.
00046                          */
00047                         if (config.action() == configuration_manager::action_help) {
00048                                 print_help();
00049                         }
00050                         else if (config.action() == configuration_manager::action_version) {
00051                                 print_version();
00052                         }
00053                         else if (config.action() == configuration_manager::action_archive) {
00054                                 timer t;
00055 
00056                                 t.start();
00057 
00058                                 logger.init();
00059                                 vaulter.init();
00060                                 reporter.init();
00061                                 archiver.init();
00062                                 cataloger.init();
00063                                 reporter.init();
00064                                 archiver.archive();
00065                                 cataloger.catalog();
00066 
00067                                 t.stop();
00068 
00069                                 reporter.set_total_time(t);
00070 
00071                                 reporter.print_report();
00072                                 reporter.file_report();
00073                         }
00074                         else if (config.action() == configuration_manager::action_relink) {
00075                                 logger.init();
00076                                 cataloger.init();
00077                                 cataloger.catalog();
00078                         }
00079                         else if (config.action() == configuration_manager::action_check_config) {
00080                                 // return(0);
00081                         }
00082                         else {
00083                                 // This should never happen
00084                                 throw(INTERNAL_ERROR(0,"Unknown action"));
00085                         }
00086                 }
00087                 catch(error e) {
00088                         std::cerr << e << std::endl;
00089                         logger.write(e.str());
00090                 }
00091                 catch(...) {
00092                         std::cerr << err_unknown << std::endl;
00093                         logger.write(err_unknown.str());
00094                         exit_manager.assign(exitstat::other_error);
00095                 }
00096         }
00097 
00098         if (exit_manager.value() == exitstat::config_error)
00099                 return(1);
00100         else if (exit_manager.value() == exitstat::vault_full)
00101                 return(2);
00102         else if (exit_manager.value() == exitstat::job_failed)
00103                 return(3);
00104         else if (exit_manager.value() == exitstat::other_error)
00105                 return(4);
00106         return(0);
00107 }
00108 

Generated on Wed Jun 21 10:50:04 2006 for rvm by  doxygen 1.4.2