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

Loading...
Searching...
No Matches
command_line.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2026 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, see the AUTHOR file
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 U_I compression_block_size;
88 infinint pause;
89 bool beep;
90 bool empty_dir;
91 mask * ea_mask;
92 string input_pipe;
93 string output_pipe;
94 comparison_fields what_to_check;
95 string execute;
96 string execute_ref;
97 secu_string pass;
98 vector<string> signatories;
99 bool blind_signatures;
100 secu_string pass_ref;
101 mask * compress_mask;
102 bool flat;
103 infinint min_compr_size;
104 bool nodump;
105 bool exclude_by_ea;
106 string ea_name_for_exclusion;
107 infinint hourshift;
108 bool warn_remove_no_match;
109 bool filter_unsaved;
110 bool empty;
111 bool alter_atime;
112 bool same_fs;
113 deque<string> same_fs_incl;
114 deque<string> same_fs_excl;
115 bool snapshot;
116 bool cache_directory_tagging;
117 U_32 crypto_size;
118 U_32 crypto_size_ref;
119 archive_options_listing_shell::listformat list_mode;
120 path * aux_root;
121 string * aux_filename;
122 secu_string aux_pass;
123 string aux_execute;
124 U_32 aux_crypto_size;
125 bool keep_compressed;
126 infinint fixed_date;
127 bool quiet;
128 bool quiet_crypto;
129 const crit_action * overwrite;
130 string slice_perm;
131 string slice_user;
132 string slice_group;
133 infinint repeat_count;
134 infinint repeat_byte;
135 bool decremental;
136 bool furtive_read_mode;
137 bool lax;
138 bool use_sequential_marks;
139 bool sequential_read;
140 infinint sparse_file_min_size;
141 dirty_behavior dirty;
142 bool security_check;
143 string user_comment;
144 hash_algo hash;
145 infinint num_digits;
146 infinint ref_num_digits;
147 infinint aux_num_digits;
148 bool only_deleted;
149 bool not_deleted;
150 mask * backup_hook_mask;
151 string backup_hook_execute;
152 bool list_ea;
153 bool ignore_unknown_inode;
154 bool no_compare_symlink_date;
155 fsa_scope scope;
156 U_I multi_threaded_crypto;
157 U_I multi_threaded_compress;
158 bool delta_sig;
159 mask *delta_mask;
160 bool delta_diff;
161 infinint delta_sig_min_size;
162 ent_params remote;
163 ent_params ref_remote;
164 ent_params aux_remote;
165 bool remote_verbose;
166 bool sizes_in_bytes;
167 bool header_only;
168 bool zeroing_neg_dates;
169 string ignored_as_symlink;
170 modified_data_detection modet;
171 infinint iteration_count;
172 hash_algo kdf_hash;
173 delta_sig_block_size delta_sig_len;
174 bool unix_sockets;
175 bool in_place;
176 bool never_resave_uncompr;
177 bool force_first_slice;
178 bool fully_detailed_dates;
179 bool isolation_repair;
180 bool extract_from_database;
181
182 // constructor for line_param
183 line_param()
184 {
185 fs_root = nullptr;
186 sauv_root = nullptr;
187 ref_root = nullptr;
188 selection = nullptr;
189 subtree = nullptr;
190 ref_filename = nullptr;
191 ea_mask = nullptr;
192 compress_mask = nullptr;
193 aux_root = nullptr;
194 aux_filename = nullptr;
195 overwrite = nullptr;
196 backup_hook_mask = nullptr;
197 };
198
199 // destructor for line_param
200 ~line_param()
201 {
202 if(fs_root != nullptr)
203 delete fs_root;
204 if(sauv_root != nullptr)
205 delete sauv_root;
206 if(ref_root != nullptr)
207 delete ref_root;
208 if(selection != nullptr)
209 delete selection;
210 if(subtree != nullptr)
211 delete subtree;
212 if(ref_filename != nullptr)
213 delete ref_filename;
214 if(ea_mask != nullptr)
215 delete ea_mask;
216 if(compress_mask != nullptr)
217 delete compress_mask;
218 if(aux_root != nullptr)
219 delete aux_root;
220 if(aux_filename != nullptr)
221 delete aux_filename;
222 if(overwrite != nullptr)
223 delete overwrite;
224 if(backup_hook_mask != nullptr)
225 delete backup_hook_mask;
226 };
227};
228
230
231 extern bool get_args(shared_ptr<user_interaction> & dialog,
232 const char *home,
233 const deque<string> & dar_dcf_path,
234 const deque<string> & dar_duc_path,
235 S_I argc,
236 char * const argv[],
237 line_param & param);
238
239
240#if HAVE_GETOPT_LONG
241 const struct option *get_long_opt();
242#endif
243
244 const char *get_short_opt();
245
247
248#endif
libdar::archive_options_listing_shell::listformat
listformat
defines the way archive listing is done:
Definition dar64-2.8.3-win64/include/dar/archive_options_listing_shell.hpp:62
libdar::crit_action
the global action for overwriting
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:81
libdar::infinint
the arbitrary large positive integer class
Definition dar64-2.8.3-win64/include/dar/real_infinint.hpp:62
libdar::mask
the generic class, parent of all masks
Definition dar64-2.8.3-win64/include/dar/mask.hpp:62
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition dar64-2.8.3-win64/include/dar/path.hpp:51
libdar::secu_string
class secu_string
Definition dar64-2.8.3-win64/include/dar/secu_string.hpp:54
libdar::modified_data_detection
modified_data_detection
how to detect data has changed when some fields
Definition dar64-2.8.3-win64/include/dar/archive_aux.hpp:44
libdar::comparison_fields
comparison_fields
how to consider file change during comparison and incremental backup
Definition dar64-2.8.3-win64/include/dar/archive_aux.hpp:53
libdar::fsa_scope
std::set< fsa_family > fsa_scope
set of fsa families
Definition dar64-2.8.3-win64/include/dar/fsa_family.hpp:70
libdar::hash_algo
hash_algo
hashing algorithm available
Definition dar64-2.8.3-win64/include/dar/archive_aux.hpp:63
libdar::compression
compression
the different compression algorithm available
Definition dar64-2.8.3-win64/include/dar/compression.hpp:46
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
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition dar64-2.8.3-win64/include/dar/archive.hpp:47
ent_params
entrepot relative parameters
Definition command_line.hpp:49
ent_params::ent_login
string ent_login
entrepot login
Definition command_line.hpp:51
ent_params::ent_pass
secu_string ent_pass
entrepot password
Definition command_line.hpp:52
ent_params::ent_host
string ent_host
entrepot hostname
Definition command_line.hpp:53
ent_params::ent_port
string ent_port
entrepot port
Definition command_line.hpp:54
ent_params::auth_from_file
bool auth_from_file
whether ~/.netrc and ~/.ssh files should be considered for credentials
Definition command_line.hpp:56
ent_params::network_retry
U_I network_retry
libcurl entrepot network retry time
Definition command_line.hpp:55
ent_params::ent_proto
string ent_proto
entrepot protocol
Definition command_line.hpp:50
libdar::delta_sig_block_size
defines how to calculate delta signature block size based of file size to delta sign
Definition dar64-2.8.3-win64/include/dar/delta_sig_block_size.hpp:50
line_param
all parameters retreived from command-line
Definition command_line.hpp:66
line_param::security_check
bool security_check
whether to signal possible root-kit presence
Definition command_line.hpp:142
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:108
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:100
line_param::filter_unsaved
bool filter_unsaved
whether to not list files that are not saved in the archive
Definition command_line.hpp:109
line_param::quiet
bool quiet
whether to display final summary for the operation
Definition command_line.hpp:127
line_param::compression_level
U_I compression_level
compression level to use when generating an archive
Definition command_line.hpp:86
line_param::isolation_repair
bool isolation_repair
whether to try isolate content of a truncated archive
Definition command_line.hpp:179
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:105
line_param::nodump
bool nodump
whether to ignore files having the "nodump" flag set when performing a backup
Definition command_line.hpp:104
line_param::filename
string filename
basename of the archive to operate on
Definition command_line.hpp:70
line_param::display_skipped
bool display_skipped
whether to display skipped files
Definition command_line.hpp:82
line_param::remote_verbose
bool remote_verbose
whether to have verbose output from libcurl
Definition command_line.hpp:165
line_param::beep
bool beep
whether to ring the terminal upon user interaction request
Definition command_line.hpp:89
line_param::subtree
mask * subtree
filter files for the operation based on path+filename
Definition command_line.hpp:76
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:141
line_param::header_only
bool header_only
whether we just display the header of archives to be read
Definition command_line.hpp:167
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::ignore_unknown_inode
bool ignore_unknown_inode
whether to ignore unknown inode types
Definition command_line.hpp:153
line_param::fixed_date
infinint fixed_date
the data for the snapshot backup
Definition command_line.hpp:126
line_param::never_resave_uncompr
bool never_resave_uncompr
never resave uncompressed when compression ratio is bad
Definition command_line.hpp:176
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:160
line_param::in_place
bool in_place
in-place restoration or comparison
Definition command_line.hpp:175
line_param::aux_execute
string aux_execute
command to be run between the slice of the auxiliary archive of reference
Definition command_line.hpp:123
line_param::blind_signatures
bool blind_signatures
whether to ignore signature check failures
Definition command_line.hpp:99
line_param::extract_from_database
bool extract_from_database
whether to extract from a dar_manager database or from a dar archive
Definition command_line.hpp:180
line_param::flat
bool flat
whether to ignore directory structure when restoring data
Definition command_line.hpp:102
line_param::crypto_size
U_32 crypto_size
block size by which to cypher data
Definition command_line.hpp:117
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
line_param::delta_sig_min_size
infinint delta_sig_min_size
size below which to never calculate delta signatures
Definition command_line.hpp:161
line_param::force_first_slice
bool force_first_slice
whether to read the first instead of the last slice when a isolated catalogue is given in complement
Definition command_line.hpp:177
line_param::multi_threaded_compress
U_I multi_threaded_compress
number of compress worker threads (requires libthreadar and per block compression)
Definition command_line.hpp:157
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:139
line_param::num_digits
infinint num_digits
minimum number of decimal for the slice number
Definition command_line.hpp:145
line_param::info_details
bool info_details
whether to show processing messages
Definition command_line.hpp:79
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:92
line_param::fs_root
path * fs_root
filesystem root
Definition command_line.hpp:68
line_param::hash
hash_algo hash
whether to produce a hash file, and which algoritm to use for that hash
Definition command_line.hpp:144
line_param::decremental
bool decremental
whether to produce a decremental backup (when merging)
Definition command_line.hpp:135
line_param::remote
ent_params remote
remote entrepot coordinates
Definition command_line.hpp:162
line_param::op
operation op
which operation to perform
Definition command_line.hpp:67
line_param::scope
fsa_scope scope
FSA scope to consider for the operation.
Definition command_line.hpp:155
line_param::what_to_check
comparison_fields what_to_check
what fields to take into account when comparing/restoring files,
Definition command_line.hpp:94
line_param::aux_remote
ent_params aux_remote
remote entrepot coordinates for the auxiliary archive
Definition command_line.hpp:164
line_param::aux_filename
string * aux_filename
basename of the auxiliary archive if reference (nullptr => no auxiliary of reference)
Definition command_line.hpp:121
line_param::pass
secu_string pass
if not an empty string, encrypt the archive with the given algo:pass string
Definition command_line.hpp:97
line_param::repeat_byte
infinint repeat_byte
archive total maximum amount of byte to waste re-saving changing files
Definition command_line.hpp:134
line_param::unix_sockets
bool unix_sockets
whether to restore unix-sockets
Definition command_line.hpp:174
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:111
line_param::slice_group
string slice_group
group to set when creating a slice
Definition command_line.hpp:132
line_param::keep_compressed
bool keep_compressed
when merging, whether to not uncompress/re-compress data in the process
Definition command_line.hpp:125
line_param::display_masks
bool display_masks
whether to display masks value
Definition command_line.hpp:84
line_param::kdf_hash
hash_algo kdf_hash
hash algo used for key derivation function
Definition command_line.hpp:172
line_param::compress_mask
mask * compress_mask
which file to compress
Definition command_line.hpp:101
line_param::delta_sig
bool delta_sig
whether to calculate rsync signature of files
Definition command_line.hpp:158
line_param::not_deleted
bool not_deleted
whether to ignore deleted files
Definition command_line.hpp:149
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::execute
string execute
if not an empty string, the command to execute between slices
Definition command_line.hpp:95
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:90
line_param::use_sequential_marks
bool use_sequential_marks
whether to add escape sequential marks in the archive
Definition command_line.hpp:138
line_param::quiet_crypto
bool quiet_crypto
do not display message about impossibility do detect wrong key when reading ciphered backup
Definition command_line.hpp:128
line_param::zeroing_neg_dates
bool zeroing_neg_dates
whether to automatically zeroing negative dates while reading inode from filesystem
Definition command_line.hpp:168
line_param::fully_detailed_dates
bool fully_detailed_dates
whether to show subsecond value of dates
Definition command_line.hpp:178
line_param::delta_mask
mask * delta_mask
which file to calculate delta sig when not using the default mask
Definition command_line.hpp:159
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:120
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:116
line_param::overwrite
const crit_action * overwrite
the overwriting policy
Definition command_line.hpp:129
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:93
line_param::empty
bool empty
whether to do a dry-run execution
Definition command_line.hpp:110
line_param::algo
compression algo
compression algorithm to use when generating an archive
Definition command_line.hpp:85
line_param::min_compr_size
infinint min_compr_size
below which size to never try compressing files
Definition command_line.hpp:103
line_param::slice_perm
string slice_perm
permission to set when creating a slice
Definition command_line.hpp:130
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:106
line_param::slice_user
string slice_user
user to set when creating a slice
Definition command_line.hpp:131
line_param::list_mode
archive_options_listing_shell::listformat list_mode
type of listing to follow
Definition command_line.hpp:119
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:146
line_param::same_fs_incl
deque< string > same_fs_incl
optional list of path to filesystems to stick to (for backup operation)
Definition command_line.hpp:113
line_param::ref_root
path * ref_root
where is the archive of reference
Definition command_line.hpp:71
line_param::aux_pass
secu_string aux_pass
crypto to use for the auxiliary archive
Definition command_line.hpp:122
line_param::only_deleted
bool only_deleted
whether to only consider deleted files
Definition command_line.hpp:148
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:133
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:140
line_param::warn_over
bool warn_over
whether to warn before overwriting files or slices
Definition command_line.hpp:78
line_param::list_ea
bool list_ea
whether to list Extended Attribute of files
Definition command_line.hpp:152
line_param::backup_hook_execute
string backup_hook_execute
which command to execute as backup hook
Definition command_line.hpp:151
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:170
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:154
line_param::multi_threaded_crypto
U_I multi_threaded_crypto
number of crypto worker threads (requires libthreadar)
Definition command_line.hpp:156
line_param::snapshot
bool snapshot
whether to perform a snapshot backup
Definition command_line.hpp:115
line_param::allow_over
bool allow_over
whether to allow slice overwriting
Definition command_line.hpp:77
line_param::first_file_size
infinint first_file_size
sice of the first slice to create
Definition command_line.hpp:74
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:166
line_param::backup_hook_mask
mask * backup_hook_mask
which file have to considered for backup hook
Definition command_line.hpp:150
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:147
line_param::delta_sig_len
delta_sig_block_size delta_sig_len
block len to used for delta signature computation
Definition command_line.hpp:173
line_param::sauv_root
path * sauv_root
where is the archive to operate on (create, read, etc.)
Definition command_line.hpp:69
line_param::compression_block_size
U_I compression_block_size
compression block size (0 for legacy compression method)
Definition command_line.hpp:87
line_param::pause
infinint pause
whether to pause between slices
Definition command_line.hpp:88
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:124
line_param::iteration_count
infinint iteration_count
iteration count used when creating/isolating/merging an encrypted archive (key derivation)
Definition command_line.hpp:171
line_param::lax
bool lax
whether to activate the last chance recovery mode (use with caution!)
Definition command_line.hpp:137
line_param::user_comment
string user_comment
user comment to add to the archive
Definition command_line.hpp:143
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:169
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:107
line_param::ea_mask
mask * ea_mask
which EA to work on
Definition command_line.hpp:91
line_param::file_size
infinint file_size
size of the slices to create (except the first)
Definition command_line.hpp:73
line_param::same_fs_excl
deque< string > same_fs_excl
optional list of path to filesystems to not consider (for backup operation)
Definition command_line.hpp:114
line_param::ref_remote
ent_params ref_remote
remote entrepot coordinates for archive of reference
Definition command_line.hpp:163
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:96
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:118
line_param::same_fs
bool same_fs
whether to stick to a same filesystem
Definition command_line.hpp:112
line_param::selection
mask * selection
filter files for the operation based on filename only
Definition command_line.hpp:75
line_param::signatories
vector< string > signatories
list of email's key to use to sign the archive
Definition command_line.hpp:98
line_param::display_treated
bool display_treated
whether to show treated files
Definition command_line.hpp:80
line_param::furtive_read_mode
bool furtive_read_mode
whether to use the furtive read mode
Definition command_line.hpp:136