|
Disk ARchive
2.4.12
|
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 00025 00026 #ifndef COMMAND_LINE_HPP 00027 #define COMMAND_LINE_HPP 00028 00029 #include "../my_config.h" 00030 #include <string> 00031 #include <vector> 00032 #include "infinint.hpp" 00033 #include "compressor.hpp" 00034 #include "mask.hpp" 00035 #include "path.hpp" 00036 #include "catalogue.hpp" 00037 #include "archive.hpp" 00038 #include "criterium.hpp" 00039 00040 using namespace std; 00041 using namespace libdar; 00042 00045 00046 enum operation { noop, extract, create, diff, test, listing, isolate, merging, version_or_help }; 00047 // noop stands for no-operation. get_args() never returns such value, 00048 // it is just necessary within the command_line module 00049 00050 enum dirty_behavior { dirtyb_ignore, dirtyb_warn, dirtyb_ok }; 00051 00052 // all parameters retreived from command-line 00053 struct line_param 00054 { 00055 operation op; //< which operation to perform 00056 path * fs_root; //< filesystem root 00057 path * sauv_root; //< where is the archive to operate on (create, read, etc.) 00058 string filename; //< basename of the archive to operate on 00059 path * ref_root; //< where is the archive of reference 00060 string * ref_filename; //< basename of the archive of reference (NULL => no archive of reference) 00061 infinint file_size; //< size of the slices to create (except the first) 00062 infinint first_file_size; //< sice of the first slice to create 00063 mask * selection; //< filter files for the operation based on filename only 00064 mask * subtree; //< filter files for the operation based on path+filename 00065 bool allow_over; //< whether to allow slice overwriting 00066 bool warn_over; //< whether to warn before overwriting files or slices 00067 bool info_details; //< whether to be verbose 00068 compression algo; //< compression algorithm to use when generating an archive 00069 U_I compression_level; //< compression level to use when generating an archive 00070 infinint pause; //< whether to pause between slices 00071 bool beep; //< whether to ring the terminal upon user interaction request 00072 bool empty_dir; //< whether to store skipped directories as empty, whether to avoid restoring directory where no data is to be restored 00073 mask * ea_mask; //< which EA to work on 00074 string input_pipe; //< if not an empty string, name of the pipe through which to read data from dar_slave 00075 string output_pipe; //< if not an empty string, name of the pipe through which to write orders to dar_slave 00076 inode::comparison_fields what_to_check; //< what fields to take into account when comparing/restoring files, 00077 string execute; //< if not an empty string, the command to execute between slices 00078 string execute_ref; //< if not an empty string, the command to execute between slices of the archive of reference 00079 secu_string pass; //< if not an empty string, encrypt the archive with the given algo:pass string 00080 secu_string pass_ref; //< if not an empty string, use the provided encryption scheme to read the archive of reference 00081 mask * compress_mask; //< which file to compress 00082 bool flat; //< whether to ignore directory structure when restoring data 00083 infinint min_compr_size; //< below which size to never try compressing files 00084 bool nodump; //< whether to ignore files having the "nodump" flag set when performing a backup 00085 infinint hourshift; //< consider equal two dates that have an integer hour of difference equal or less than hourshift 00086 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 00087 bool filter_unsaved; //< whether to not list files that are not saved in the archive 00088 bool empty; //< whether to do a dry-run execution 00089 bool alter_atime; //< whether to reset the atime of file read during backup to their original value (resetting atime does modify ctime) 00090 bool same_fs; //< whether to stick to a same filesystem 00091 bool snapshot; //< whether to perform a snapshot backup 00092 bool cache_directory_tagging; //< whether to ignore directory contents where a the cache directory tagging files is found 00093 U_32 crypto_size; //< block size by which to cypher data 00094 U_32 crypto_size_ref; //< block size by which to uncypher data from the archive of reference 00095 bool display_skipped; //< whether to display skipped files 00096 archive_options_listing::listformat list_mode; //< type of listing to follow 00097 path * aux_root; //< where is the auxiliary archive of reference [used for merging but also when creating an archive, for the on-fly isolation] 00098 string * aux_filename; //< basename of the auxiliary archive if reference (NULL => no auxiliary of reference) 00099 secu_string aux_pass; //< crypto to use for the auxiliary archive 00100 string aux_execute; //< command to be run between the slice of the auxiliary archive of reference 00101 U_32 aux_crypto_size; //< block size by which to cypher/uncypher data to/from the auxiliary archive of reference 00102 bool keep_compressed; //< when merging, whether to not uncompress/re-compress data in the process 00103 infinint fixed_date; //< the data for the snapshot backup 00104 bool quiet; //< whether to display final summary for the operation 00105 const crit_action * overwrite;//< the overwriting policy 00106 string slice_perm; //< permission to set when creating a slice 00107 string slice_user; //< user to set when creating a slice 00108 string slice_group; //< group to set when creating a slice 00109 infinint repeat_count; //< number of time to try saving a file if it changes at the time it is read for backup 00110 infinint repeat_byte; //< archive total maximum amount of byte to waste re-saving changing files 00111 bool decremental; //< whether to produce a decremental backup (when merging) 00112 bool furtive_read_mode; //< whether to use the furtive read mode 00113 bool lax; //< whether to activate the last chance recovery mode (use with caution!) 00114 bool use_sequential_marks; //< whether to add escape sequential marks in the archive 00115 bool sequential_read; //< whether to follow escape sequential marks to achieve a sequential reading of the archive 00116 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 00117 dirty_behavior dirty; //< what to do when comes the time to restore a file that is flagged as dirty 00118 bool security_check; //< whether to signal possible root-kit presence 00119 string user_comment; //< user comment to add to the archive 00120 hash_algo hash; //< whether to produce a hash file, and which algoritm to use for that hash 00121 infinint num_digits; //< minimum number of decimal for the slice number 00122 infinint ref_num_digits; //< minimum number of decimal for the slice number of the archive of reference 00123 infinint aux_num_digits; //< minimum number of decimal for the slice number of the auxiliary archive of reference 00124 bool only_deleted; //< whether to only consider deleted files 00125 bool not_deleted; //< whether to ignore deleted files 00126 mask * backup_hook_mask; //< which file have to considered for backup hook 00127 string backup_hook_execute; //< which command to execute as backup hook 00128 bool list_ea; //< whether to list Extended Attribute of files 00129 bool ignore_unknown_inode; //< whether to ignore unknown inode types 00130 bool no_compare_symlink_date; //< whether to report difference in dates of symlinks while diffing an archive with filesystem 00131 00132 // constructor for line_param 00133 line_param() 00134 { 00135 fs_root= NULL; 00136 sauv_root = NULL; 00137 ref_root = NULL; 00138 selection = NULL; 00139 subtree = NULL; 00140 ref_filename = NULL; 00141 ea_mask = NULL; 00142 compress_mask = NULL; 00143 aux_root = NULL; 00144 aux_filename = NULL; 00145 overwrite = NULL; 00146 backup_hook_mask = NULL; 00147 }; 00148 00149 // destructor for line_param 00150 ~line_param() 00151 { 00152 if(fs_root != NULL) 00153 delete fs_root; 00154 if(sauv_root != NULL) 00155 delete sauv_root; 00156 if(ref_root != NULL) 00157 delete ref_root; 00158 if(selection != NULL) 00159 delete selection; 00160 if(subtree != NULL) 00161 delete subtree; 00162 if(ref_filename != NULL) 00163 delete ref_filename; 00164 if(ea_mask != NULL) 00165 delete ea_mask; 00166 if(compress_mask != NULL) 00167 delete compress_mask; 00168 if(aux_root != NULL) 00169 delete aux_root; 00170 if(aux_filename != NULL) 00171 delete aux_filename; 00172 if(overwrite != NULL) 00173 delete overwrite; 00174 if(backup_hook_mask != NULL) 00175 delete backup_hook_mask; 00176 }; 00177 }; 00178 00180 00181 extern bool get_args(user_interaction & dialog, 00182 const char *home, 00183 const vector<string> & dar_dcf_path, 00184 const vector<string> & dar_duc_path, 00185 S_I argc, 00186 char * const argv[], 00187 line_param & param); 00188 00190 00191 #if HAVE_GETOPT_LONG 00192 const struct option *get_long_opt(); 00193 #endif 00194 00195 const char *get_short_opt(); 00196 #endif
1.7.6.1