| Disk ARchive 2.6.12 Full featured and portable backup and archiving tool

command_line.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26 #ifndef COMMAND_LINE_HPP
27 #define COMMAND_LINE_HPP
28
29 #include "../my_config.h"
30 #include <string>
31 #include <deque>
32 #include <vector>
33 #include "libdar.hpp"
34
35 using namespace std;
36 using namespace libdar;
37
40
41 enum operation { noop, extract, create, diff, test, listing, isolate, merging, version_or_help, repairing };
42 // noop stands for no-operation. get_args() never returns such value,
43 // it is just necessary within the command_line module
44
45 enum dirty_behavior { dirtyb_ignore, dirtyb_warn, dirtyb_ok };
46
48 struct ent_params
49 {
50 string ent_proto;
51 string ent_login;
52 secu_string ent_pass;
53 string ent_host;
54 string ent_port;
55 U_I network_retry;
56 bool auth_from_file;
57
58 void clear()
59 { ent_proto.clear(); ent_login.clear(); ent_pass.clear();
60 ent_host.clear(); ent_port.clear(); network_retry = 3;
61 auth_from_file = false; };
62 };
63
65 struct line_param
66 {
67 operation op;
68 path * fs_root;
69 path * sauv_root;
70 string filename;
71 path * ref_root;
72 string * ref_filename;
73 infinint file_size;
74 infinint first_file_size;
75 mask * selection;
76 mask * subtree;
77 bool allow_over;
78 bool warn_over;
79 bool info_details;
80 bool display_treated;
81 bool display_treated_only_dir;
82 bool display_skipped;
83 bool display_finished;
84 bool display_masks;
85 compression algo;
86 U_I compression_level;
87 infinint pause;
88 bool beep;
89 bool empty_dir;
90 mask * ea_mask;
91 string input_pipe;
92 string output_pipe;
93 comparison_fields what_to_check;
94 string execute;
95 string execute_ref;
96 secu_string pass;
97 vector<string> signatories;
98 bool blind_signatures;
99 secu_string pass_ref;
100 mask * compress_mask;
101 bool flat;
102 infinint min_compr_size;
103 bool nodump;
104 bool exclude_by_ea;
105 string ea_name_for_exclusion;
106 infinint hourshift;
107 bool warn_remove_no_match;
108 bool filter_unsaved;
109 bool empty;
110 bool alter_atime;
111 bool same_fs;
112 bool snapshot;
113 bool cache_directory_tagging;
114 U_32 crypto_size;
115 U_32 crypto_size_ref;
116 archive_options_listing_shell::listformat list_mode;
117 path * aux_root;
118 string * aux_filename;
119 secu_string aux_pass;
120 string aux_execute;
121 U_32 aux_crypto_size;
122 bool keep_compressed;
123 infinint fixed_date;
124 bool quiet;
125 const crit_action * overwrite;
126 string slice_perm;
127 string slice_user;
128 string slice_group;
129 infinint repeat_count;
130 infinint repeat_byte;
131 bool decremental;
132 bool furtive_read_mode;
133 bool lax;
134 bool use_sequential_marks;
135 bool sequential_read;
136 infinint sparse_file_min_size;
137 dirty_behavior dirty;
138 bool security_check;
139 string user_comment;
140 hash_algo hash;
141 infinint num_digits;
142 infinint ref_num_digits;
143 infinint aux_num_digits;
144 bool only_deleted;
145 bool not_deleted;
146 mask * backup_hook_mask;
147 string backup_hook_execute;
148 bool list_ea;
149 bool ignore_unknown_inode;
150 bool no_compare_symlink_date;
151 fsa_scope scope;
152 bool multi_threaded;
153 bool delta_sig;
154 mask *delta_mask;
155 bool delta_diff;
156 infinint delta_sig_min_size;
157 ent_params remote;
158 ent_params ref_remote;
159 ent_params aux_remote;
160 bool sizes_in_bytes;
161 bool header_only;
162 bool zeroing_neg_dates;
163 string ignored_as_symlink;
164 modified_data_detection modet;
165 infinint iteration_count;
166 hash_algo kdf_hash;
167 delta_sig_block_size delta_sig_len;
168
169 // constructor for line_param
170 line_param()
171 {
172 fs_root = nullptr;
173 sauv_root = nullptr;
174 ref_root = nullptr;
175 selection = nullptr;
176 subtree = nullptr;
177 ref_filename = nullptr;
178 ea_mask = nullptr;
179 compress_mask = nullptr;
180 aux_root = nullptr;
181 aux_filename = nullptr;
182 overwrite = nullptr;
183 backup_hook_mask = nullptr;
184 };
185
186 // destructor for line_param
187 ~line_param()
188 {
189 if(fs_root != nullptr)
190 delete fs_root;
191 if(sauv_root != nullptr)
192 delete sauv_root;
193 if(ref_root != nullptr)
194 delete ref_root;
195 if(selection != nullptr)
196 delete selection;
197 if(subtree != nullptr)
198 delete subtree;
199 if(ref_filename != nullptr)
200 delete ref_filename;
201 if(ea_mask != nullptr)
202 delete ea_mask;
203 if(compress_mask != nullptr)
204 delete compress_mask;
205 if(aux_root != nullptr)
206 delete aux_root;
207 if(aux_filename != nullptr)
208 delete aux_filename;
209 if(overwrite != nullptr)
210 delete overwrite;
211 if(backup_hook_mask != nullptr)
212 delete backup_hook_mask;
213 };
214 };
215
217
218 extern bool get_args(shared_ptr<user_interaction> & dialog,
219 const char *home,
220 const deque<string> & dar_dcf_path,
221 const deque<string> & dar_duc_path,
222 S_I argc,
223 char * const argv[],
224 line_param & param);
225
226
227 #if HAVE_GETOPT_LONG
228 const struct option *get_long_opt();
229 #endif
230
231 const char *get_short_opt();
232
234
235 #endif
line_param::cache_directory_tagging
bool cache_directory_tagging
whether to ignore directory contents where a the cache directory tagging files is found
Definition: command_line.hpp:113
line_param::display_treated_only_dir
bool display_treated_only_dir
whether to show treated files's current working directory
Definition: command_line.hpp:81
libdar::hash_algo
hash_algo
hashing algorithm available
Definition: archive_aux.hpp:63
line_param::warn_remove_no_match
bool warn_remove_no_match
whether to warn file about to be removed during a restoration, when they to no match the expected typ...
Definition: command_line.hpp:107
line_param::ignore_unknown_inode
bool ignore_unknown_inode
whether to ignore unknown inode types
Definition: command_line.hpp:149
line_param::backup_hook_execute
string backup_hook_execute
which command to execute as backup hook
Definition: command_line.hpp:147
line_param::list_mode
archive_options_listing_shell::listformat list_mode
type of listing to follow
Definition: command_line.hpp:116
line_param::slice_user
string slice_user
user to set when creating a slice
Definition: command_line.hpp:127
line_param::slice_group
string slice_group
group to set when creating a slice
Definition: command_line.hpp:128
line_param::aux_root
path * aux_root
where is the auxiliary archive of reference [used for merging but also when creating an archive,...
Definition: command_line.hpp:117
line_param::empty
bool empty
whether to do a dry-run execution
Definition: command_line.hpp:109
line_param::ea_name_for_exclusion
string ea_name_for_exclusion
EA name to use for file exclusion, or empty string for the default EA name.
Definition: command_line.hpp:105
libdar::compression
compression
the different compression algorithm available
Definition: compression.hpp:46
line_param::display_masks
bool display_masks
whether to display masks value
Definition: command_line.hpp:84
line_param::scope
fsa_scope scope
FSA scope to consider for the operation.
Definition: command_line.hpp:151
line_param::execute_ref
string execute_ref
if not an empty string, the command to execute between slices of the archive of reference
Definition: command_line.hpp:95
line_param::repeat_byte
infinint repeat_byte
archive total maximum amount of byte to waste re-saving changing files
Definition: command_line.hpp:130
get_args
bool get_args(shared_ptr< user_interaction > &dialog, const char *home, const deque< string > &dar_dcf_path, const deque< string > &dar_duc_path, S_I argc, char *const argv[], line_param &param)
main routine to extract parameters from command-line and included files
line_param::ignored_as_symlink
string ignored_as_symlink
column separated list of absolute paths of links to follow rather to record as such
Definition: command_line.hpp:163
line_param::filter_unsaved
bool filter_unsaved
whether to not list files that are not saved in the archive
Definition: command_line.hpp:108
line_param::aux_num_digits
infinint aux_num_digits
minimum number of decimal for the slice number of the auxiliary archive of reference
Definition: command_line.hpp:143
line_param::input_pipe
string input_pipe
if not an empty string, name of the pipe through which to read data from dar_slave
Definition: command_line.hpp:91
line_param::aux_execute
string aux_execute
command to be run between the slice of the auxiliary archive of reference
Definition: command_line.hpp:120
line_param::lax
bool lax
whether to activate the last chance recovery mode (use with caution!)
Definition: command_line.hpp:133
line_param::security_check
bool security_check
whether to signal possible root-kit presence
Definition: command_line.hpp:138
line_param::aux_crypto_size
U_32 aux_crypto_size
block size by which to cypher/uncypher data to/from the auxiliary archive of reference
Definition: command_line.hpp:121
line_param::quiet
bool quiet
whether to display final summary for the operation
Definition: command_line.hpp:124
line_param::sparse_file_min_size
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
Definition: command_line.hpp:136
ent_params::ent_login
string ent_login
entrepot login
Definition: command_line.hpp:51
line_param::sizes_in_bytes
bool sizes_in_bytes
whether to display sizes in bytes of to the larges unit (Mo, Go, To,...)
Definition: command_line.hpp:160
line_param::sequential_read
bool sequential_read
whether to follow escape sequential marks to achieve a sequential reading of the archive
Definition: command_line.hpp:135
ent_params::ent_proto
string ent_proto
entrepot protocol
Definition: command_line.hpp:50
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:62
line_param::hourshift
infinint hourshift
consider equal two dates that have an integer hour of difference equal or less than hourshift
Definition: command_line.hpp:106
line_param::signatories
vector< string > signatories
list of email's key to use to sign the archive
Definition: command_line.hpp:97
line_param::compress_mask
mask * compress_mask
which file to compress
Definition: command_line.hpp:100
line_param::fs_root
path * fs_root
filesystem root
Definition: command_line.hpp:68
libdar::mask
the generic class, parent of all masks
Definition: mask.hpp:62
line_param::iteration_count
infinint iteration_count
iteration count used when creating/isolating/merging an encrypted archive (key derivation)
Definition: command_line.hpp:165
line_param::nodump
bool nodump
whether to ignore files having the "nodump" flag set when performing a backup
Definition: command_line.hpp:103
ent_params::ent_pass
secu_string ent_pass
entrepot password
Definition: command_line.hpp:52
line_param::ref_num_digits
infinint ref_num_digits
minimum number of decimal for the slice number of the archive of reference
Definition: command_line.hpp:142
ent_params::auth_from_file
bool auth_from_file
whether ~/.netrc and ~/.ssh files should be considered for credentials
Definition: command_line.hpp:56
line_param::subtree
mask * subtree
filter files for the operation based on path+filename
Definition: command_line.hpp:76
line_param::beep
bool beep
whether to ring the terminal upon user interaction request
Definition: command_line.hpp:88
line_param::repeat_count
infinint repeat_count
number of time to try saving a file if it changes at the time it is read for backup
Definition: command_line.hpp:129
line_param::use_sequential_marks
bool use_sequential_marks
whether to add escape sequential marks in the archive
Definition: command_line.hpp:134
line_param::aux_pass
secu_string aux_pass
crypto to use for the auxiliary archive
Definition: command_line.hpp:119
line_param::warn_over
bool warn_over
whether to warn before overwriting files or slices
Definition: command_line.hpp:78
line_param::pass_ref
secu_string pass_ref
if not an empty string, use the provided encryption scheme to read the archive of reference
Definition: command_line.hpp:99
line_param::hash
hash_algo hash
whether to produce a hash file, and which algoritm to use for that hash
Definition: command_line.hpp:140
line_param
all parameters retreived from command-line
Definition: command_line.hpp:66
line_param::no_compare_symlink_date
bool no_compare_symlink_date
whether to report difference in dates of symlinks while diffing an archive with filesystem
Definition: command_line.hpp:150
line_param::op
operation op
which operation to perform
Definition: command_line.hpp:67
line_param::flat
bool flat
whether to ignore directory structure when restoring data
Definition: command_line.hpp:101
line_param::pass
secu_string pass
if not an empty string, encrypt the archive with the given algo:pass string
Definition: command_line.hpp:96
line_param::header_only
bool header_only
whether we just display the header of archives to be read
Definition: command_line.hpp:161
line_param::decremental
bool decremental
whether to produce a decremental backup (when merging)
Definition: command_line.hpp:131
line_param::display_finished
bool display_finished
whether to display summary (space/compression ratio) for each completed directory
Definition: command_line.hpp:83
line_param::aux_remote
ent_params aux_remote
remote entrepot coordinates for the auxiliary archive
Definition: command_line.hpp:159
line_param::alter_atime
bool alter_atime
whether to reset the atime of file read during backup to their original value (resetting atime does m...
Definition: command_line.hpp:110
line_param::what_to_check
comparison_fields what_to_check
what fields to take into account when comparing/restoring files,
Definition: command_line.hpp:93
line_param::list_ea
bool list_ea
whether to list Extended Attribute of files
Definition: command_line.hpp:148
line_param::min_compr_size
infinint min_compr_size
below which size to never try compressing files
Definition: command_line.hpp:102
line_param::display_skipped
bool display_skipped
whether to display skipped files
Definition: command_line.hpp:82
line_param::multi_threaded
bool multi_threaded
allows libdar to use multiple threads (requires libthreadar)
Definition: command_line.hpp:152
line_param::pause
infinint pause
whether to pause between slices
Definition: command_line.hpp:87
line_param::furtive_read_mode
bool furtive_read_mode
whether to use the furtive read mode
Definition: command_line.hpp:132
line_param::kdf_hash
hash_algo kdf_hash
hash algo used for key derivation function
Definition: command_line.hpp:166
line_param::output_pipe
string output_pipe
if not an empty string, name of the pipe through which to write orders to dar_slave
Definition: command_line.hpp:92
ent_params
entrepot relative parameters
Definition: command_line.hpp:49
line_param::crypto_size
U_32 crypto_size
block size by which to cypher data
Definition: command_line.hpp:114
line_param::first_file_size
infinint first_file_size
sice of the first slice to create
Definition: command_line.hpp:74
line_param::zeroing_neg_dates
bool zeroing_neg_dates
whether to automatically zeroing negative dates while reading inode from filesystem
Definition: command_line.hpp:162
line_param::slice_perm
string slice_perm
permission to set when creating a slice
Definition: command_line.hpp:126
ent_params::network_retry
U_I network_retry
libcurl entrepot network retry time
Definition: command_line.hpp:55
ent_params::ent_port
string ent_port
entrepot port
Definition: command_line.hpp:54
line_param::modet
modified_data_detection modet
how to detect that a file has changed since the archive of reference was done
Definition: command_line.hpp:164
libdar::delta_sig_block_size
defines how to calculate delta signature block size based of file size to delta sign
Definition: delta_sig_block_size.hpp:47
line_param::empty_dir
bool empty_dir
whether to store skipped directories as empty, whether to avoid restoring directory where no data is ...
Definition: command_line.hpp:89
line_param::selection
mask * selection
filter files for the operation based on filename only
Definition: command_line.hpp:75
line_param::keep_compressed
bool keep_compressed
when merging, whether to not uncompress/re-compress data in the process
Definition: command_line.hpp:122
line_param::num_digits
infinint num_digits
minimum number of decimal for the slice number
Definition: command_line.hpp:141
line_param::overwrite
const crit_action * overwrite
the overwriting policy
Definition: command_line.hpp:125
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:51
line_param::fixed_date
infinint fixed_date
the data for the snapshot backup
Definition: command_line.hpp:123
line_param::info_details
bool info_details
whether to show processing messages
Definition: command_line.hpp:79
line_param::delta_sig
bool delta_sig
whether to calculate rsync signature of files
Definition: command_line.hpp:153
line_param::delta_mask
mask * delta_mask
which file to calculate delta sig when not using the default mask
Definition: command_line.hpp:154
line_param::crypto_size_ref
U_32 crypto_size_ref
block size by which to uncypher data from the archive of reference
Definition: command_line.hpp:115
line_param::dirty
dirty_behavior dirty
what to do when comes the time to restore a file that is flagged as dirty
Definition: command_line.hpp:137
line_param::same_fs
bool same_fs
whether to stick to a same filesystem
Definition: command_line.hpp:111
line_param::delta_sig_len
delta_sig_block_size delta_sig_len
block len to used for delta signature computation
Definition: command_line.hpp:167
line_param::exclude_by_ea
bool exclude_by_ea
whether inode have to be check against a given EA before backup
Definition: command_line.hpp:104
line_param::snapshot
bool snapshot
whether to perform a snapshot backup
Definition: command_line.hpp:112
line_param::ea_mask
mask * ea_mask
which EA to work on
Definition: command_line.hpp:90
libdar::secu_string::clear
void clear()
clear the string (set to an empty string)
Definition: secu_string.hpp:136
line_param::filename
string filename
basename of the archive to operate on
Definition: command_line.hpp:70
line_param::ref_filename
string * ref_filename
basename of the archive of reference (nullptr => no archive of reference)
Definition: command_line.hpp:72
line_param::sauv_root
path * sauv_root
where is the archive to operate on (create, read, etc.)
Definition: command_line.hpp:69
line_param::delta_diff
bool delta_diff
whether to save binary diff or whole file's data during a differential backup
Definition: command_line.hpp:155
libdar::comparison_fields
comparison_fields
how to consider file change during comparison and incremental backup
Definition: archive_aux.hpp:53
ent_params::ent_host
string ent_host
entrepot hostname
Definition: command_line.hpp:53
libdar::secu_string
class secu_string
Definition: secu_string.hpp:58
line_param::algo
compression algo
compression algorithm to use when generating an archive
Definition: command_line.hpp:85
line_param::file_size
infinint file_size
size of the slices to create (except the first)
Definition: command_line.hpp:73
line_param::not_deleted
bool not_deleted
whether to ignore deleted files
Definition: command_line.hpp:145
line_param::delta_sig_min_size
infinint delta_sig_min_size
size below which to never calculate delta signatures
Definition: command_line.hpp:156
line_param::user_comment
string user_comment
user comment to add to the archive
Definition: command_line.hpp:139
line_param::backup_hook_mask
mask * backup_hook_mask
which file have to considered for backup hook
Definition: command_line.hpp:146
line_param::compression_level
U_I compression_level
compression level to use when generating an archive
Definition: command_line.hpp:86
line_param::execute
string execute
if not an empty string, the command to execute between slices
Definition: command_line.hpp:94
libdar::archive_options_listing_shell::listformat
listformat
defines the way archive listing is done:
Definition: archive_options_listing_shell.hpp:62
line_param::ref_remote
ent_params ref_remote
remote entrepot coordinates for archive of reference
Definition: command_line.hpp:158
line_param::aux_filename
string * aux_filename
basename of the auxiliary archive if reference (nullptr => no auxiliary of reference)
Definition: command_line.hpp:118
libdar::modified_data_detection
modified_data_detection
how to detect data has changed when some fields
Definition: archive_aux.hpp:44
line_param::allow_over
bool allow_over
whether to allow slice overwriting
Definition: command_line.hpp:77
line_param::ref_root
path * ref_root
where is the archive of reference
Definition: command_line.hpp:71
line_param::display_treated
bool display_treated
whether to show treated files
Definition: command_line.hpp:80
line_param::remote
ent_params remote
remote entrepot coordinates
Definition: command_line.hpp:157
libdar.hpp
the main file of the libdar API definitions
libdar::crit_action
the global action for overwriting
Definition: crit_action.hpp:81
line_param::blind_signatures
bool blind_signatures
whether to ignore signature check failures
Definition: command_line.hpp:98
line_param::only_deleted
bool only_deleted
whether to only consider deleted files
Definition: command_line.hpp:144
libdar::fsa_scope
std::set< fsa_family > fsa_scope
set of fsa families
Definition: fsa_family.hpp:70
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47