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