Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/dar_suite/command_line.hpp
00001 /*********************************************************************/
00002 // dar - disk archive - a backup/restoration program
00003 // Copyright (C) 2002-2052 Denis Corbin
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 // to contact the author : http://dar.linux.free.fr/email.html
00020 /*********************************************************************/
00021 // $Id$
00022 //
00023 /*********************************************************************/
00024 
00028 
00029 #ifndef COMMAND_LINE_HPP
00030 #define COMMAND_LINE_HPP
00031 
00032 #include "../my_config.h"
00033 #include <string>
00034 #include <vector>
00035 #include "infinint.hpp"
00036 #include "compressor.hpp"
00037 #include "mask.hpp"
00038 #include "path.hpp"
00039 #include "catalogue.hpp"
00040 #include "archive.hpp"
00041 #include "criterium.hpp"
00042 
00043 using namespace std;
00044 using namespace libdar;
00045 
00048 
00049 enum operation { noop, extract, create, diff, test, listing, isolate, merging };
00050     // noop stands for no-operation. get_args() never returns such value,
00051     // it is just necessary within the command_line module
00052 
00053 enum dirty_behavior { dirtyb_ignore, dirtyb_warn, dirtyb_ok };
00054 
00055     // all parameters retreived from command-line
00056 struct line_param
00057 {
00058     operation op;                 //< which operation to perform
00059     path * fs_root;               //< filesystem root
00060     path * sauv_root;             //< where is the archive to operate on (create, read, etc.)
00061     string filename;              //< basename of the archive to operate on
00062     path * ref_root;              //< where is the archive of reference
00063     string * ref_filename;        //< basename of the archive of reference (NULL => no archive of reference)
00064     infinint file_size;           //< size of the slices to create (except the first)
00065     infinint first_file_size;     //< sice of the first slice to create
00066     mask * selection;             //< filter files for the operation based on filename only
00067     mask * subtree;               //< filter files for the operation based on path+filename
00068     bool allow_over;              //< whether to allow slice overwriting
00069     bool warn_over;               //< whether to warn before overwriting files or slices
00070     bool info_details;            //< whether to be verbose
00071     compression algo;             //< compression algorithm to use when generating an archive
00072     U_I compression_level;        //< compression level to use when generating an archive
00073     infinint pause;               //< whether to pause between slices
00074     bool beep;                    //< whether to ring the terminal upon user interaction request
00075     bool empty_dir;               //< whether to store skipped directories as empty, whether to avoid restoring directory where no data is to be restored
00076     mask * ea_mask;               //< which EA to work on
00077     string input_pipe;            //< if not an empty string, name of the pipe through which to read data from dar_slave
00078     string output_pipe;           //< if not an empty string, name of the pipe through which to write orders to dar_slave
00079     inode::comparison_fields what_to_check; //< what fields to take into account when comparing/restoring files,
00080     string execute;               //< if not an empty string, the command to execute between slices
00081     string execute_ref;           //< if not an empty string, the command to execute between slices of the archive of reference
00082     secu_string pass;             //< if not an empty string, encrypt the archive with the given algo:pass string
00083     secu_string pass_ref;         //< if not an empty string, use the provided encryption scheme to read the archive of reference
00084     mask * compress_mask;         //< which file to compress
00085     bool flat;                    //< whether to ignore directory structure when restoring data
00086     infinint min_compr_size;      //< below which size to never try compressing files
00087     bool nodump;                  //< whether to ignore files having the "nodump" flag set when performing a backup
00088     infinint hourshift;           //< consider equal two dates that have an integer hour of difference equal or less than hourshift
00089     bool warn_remove_no_match;    //< whether to warn file about to be removed during a restoration, when they to no match the expected type of file
00090     bool filter_unsaved;          //< whether to not list files that are not saved in the archive
00091     bool empty;                   //< whether to do a dry-run execution
00092     bool alter_atime;             //< whether to reset the atime of file read during backup to their original value (resetting atime does modify ctime)
00093     bool same_fs;                 //< whether to stick to a same filesystem
00094     bool snapshot;                //< whether to perform a snapshot backup
00095     bool cache_directory_tagging; //< whether to ignore directory contents where a the cache directory tagging files is found
00096     U_32 crypto_size;             //< block size by which to cypher data
00097     U_32 crypto_size_ref;         //< block size by which to uncypher data from the archive of reference
00098     bool display_skipped;         //< whether to display skipped files
00099     archive_options_listing::listformat list_mode; //< type of listing to follow
00100     path * aux_root;              //< where is the auxiliary archive of reference [used for merging but also when creating an archive, for the on-fly isolation]
00101     string * aux_filename;        //< basename of the auxiliary archive if reference (NULL => no auxiliary of reference)
00102     secu_string aux_pass;         //< crypto to use for the auxiliary archive
00103     string aux_execute;           //< command to be run between the slice of the auxiliary archive of reference
00104     U_32 aux_crypto_size;         //< block size by which to cypher/uncypher data to/from the auxiliary archive of reference
00105     bool keep_compressed;         //< when merging, whether to not uncompress/re-compress data in the process
00106     infinint fixed_date;          //< the data for the snapshot backup
00107     bool quiet;                   //< whether to display final summary for the operation
00108     const crit_action * overwrite;//< the overwriting policy
00109     string slice_perm;            //< permission to set when creating a slice
00110     string slice_user;            //< user to set when creating a slice
00111     string slice_group;           //< group to set when creating a slice
00112     infinint repeat_count;        //< number of time to try saving a file if it changes at the time it is read for backup
00113     infinint repeat_byte;         //< archive total maximum amount of byte to waste re-saving changing files
00114     bool decremental;             //< whether to produce a decremental backup (when merging)
00115     bool furtive_read_mode;       //< whether to use the furtive read mode
00116     bool lax;                     //< whether to activate the last chance recovery mode (use with caution!)
00117     bool use_sequential_marks;    //< whether to add escape sequential marks in the archive
00118     bool sequential_read;         //< whether to follow escape sequential marks to achieve a sequential reading of the archive
00119     infinint sparse_file_min_size;//< minimum size of a zeroed byte sequence to be considered as a hole and stored this way in the archive
00120     dirty_behavior dirty;         //< what to do when comes the time to restore a file that is flagged as dirty
00121     bool  security_check;         //< whether to signal possible root-kit presence
00122     string user_comment;          //< user comment to add to the archive
00123     hash_algo hash;               //< whether to produce a hash file, and which algoritm to use for that hash
00124     infinint num_digits;          //< minimum number of decimal for the slice number
00125     infinint ref_num_digits;      //< minimum number of decimal for the slice number of the archive of reference
00126     infinint aux_num_digits;      //< minimum number of decimal for the slice number of the auxiliary archive of reference
00127     bool only_deleted;            //< whether to only consider deleted files
00128     bool not_deleted;             //< whether to ignore deleted files
00129     mask * backup_hook_mask;      //< which file have to considered for backup hook
00130     string backup_hook_execute;   //< which command to execute as backup hook
00131     bool list_ea;                 //< whether to list Extended Attribute of files
00132     bool ignore_unknown_inode;    //< whether to ignore unknown inode types
00133     bool no_compare_symlink_date; //< whether to report difference in dates of symlinks while diffing an archive with filesystem
00134 
00135         // constructor for line_param
00136     line_param()
00137     {
00138         fs_root= NULL;
00139         sauv_root = NULL;
00140         ref_root = NULL;
00141         selection = NULL;
00142         subtree = NULL;
00143         ref_filename = NULL;
00144         ea_mask = NULL;
00145         compress_mask = NULL;
00146         aux_root = NULL;
00147         aux_filename = NULL;
00148         overwrite = NULL;
00149         backup_hook_mask = NULL;
00150     };
00151 
00152         // destructor for line_param
00153     ~line_param()
00154     {
00155         if(fs_root != NULL)
00156             delete fs_root;
00157         if(sauv_root != NULL)
00158             delete sauv_root;
00159         if(ref_root != NULL)
00160             delete ref_root;
00161         if(selection != NULL)
00162             delete selection;
00163         if(subtree != NULL)
00164             delete subtree;
00165         if(ref_filename != NULL)
00166             delete ref_filename;
00167         if(ea_mask != NULL)
00168             delete ea_mask;
00169         if(compress_mask != NULL)
00170             delete compress_mask;
00171         if(aux_root != NULL)
00172             delete aux_root;
00173         if(aux_filename != NULL)
00174             delete aux_filename;
00175         if(overwrite != NULL)
00176             delete overwrite;
00177         if(backup_hook_mask != NULL)
00178             delete backup_hook_mask;
00179     };
00180 };
00181 
00183 
00184 extern bool get_args(user_interaction & dialog,
00185                      const char *home,
00186                      const vector<string> & dar_dcf_path,
00187                      const vector<string> & dar_duc_path,
00188                      S_I argc,
00189                      char * const argv[],
00190                      line_param & param);
00191 
00193 
00194 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines