Disk ARchive  2.7.14
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-2024 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;
53  string ent_host;
54  string ent_port;
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;
70  string filename;
72  string * ref_filename;
77  bool allow_over;
78  bool warn_over;
79  bool info_details;
89  bool beep;
90  bool empty_dir;
92  string input_pipe;
93  string output_pipe;
95  string execute;
96  string execute_ref;
98  vector<string> signatories;
102  bool flat;
104  bool nodump;
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;
117  U_32 crypto_size;
121  string * aux_filename;
123  string aux_execute;
127  bool quiet;
129  string slice_perm;
130  string slice_user;
131  string slice_group;
134  bool decremental;
136  bool lax;
140  dirty_behavior dirty;
142  string user_comment;
148  bool not_deleted;
151  bool list_ea;
157  bool delta_sig;
159  bool delta_diff;
166  bool header_only;
174  bool in_place;
175 
176  // constructor for line_param
177  line_param()
178  {
179  fs_root = nullptr;
180  sauv_root = nullptr;
181  ref_root = nullptr;
182  selection = nullptr;
183  subtree = nullptr;
184  ref_filename = nullptr;
185  ea_mask = nullptr;
186  compress_mask = nullptr;
187  aux_root = nullptr;
188  aux_filename = nullptr;
189  overwrite = nullptr;
190  backup_hook_mask = nullptr;
191  };
192 
193  // destructor for line_param
194  ~line_param()
195  {
196  if(fs_root != nullptr)
197  delete fs_root;
198  if(sauv_root != nullptr)
199  delete sauv_root;
200  if(ref_root != nullptr)
201  delete ref_root;
202  if(selection != nullptr)
203  delete selection;
204  if(subtree != nullptr)
205  delete subtree;
206  if(ref_filename != nullptr)
207  delete ref_filename;
208  if(ea_mask != nullptr)
209  delete ea_mask;
210  if(compress_mask != nullptr)
211  delete compress_mask;
212  if(aux_root != nullptr)
213  delete aux_root;
214  if(aux_filename != nullptr)
215  delete aux_filename;
216  if(overwrite != nullptr)
217  delete overwrite;
218  if(backup_hook_mask != nullptr)
219  delete backup_hook_mask;
220  };
221 };
222 
224 
225 extern bool get_args(shared_ptr<user_interaction> & dialog,
226  const char *home,
227  const deque<string> & dar_dcf_path,
228  const deque<string> & dar_duc_path,
229  S_I argc,
230  char * const argv[],
231  line_param & param);
232 
233 
234 #if HAVE_GETOPT_LONG
235 const struct option *get_long_opt();
236 #endif
237 
238 const char *get_short_opt();
239 
241 
242 #endif
listformat
defines the way archive listing is done:
the global action for overwriting
Definition: crit_action.hpp:81
the arbitrary large positive integer class
the generic class, parent of all masks
Definition: mask.hpp:62
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:51
class secu_string
Definition: secu_string.hpp:54
void clear()
clear the string (set to an empty string)
modified_data_detection
how to detect data has changed when some fields
Definition: archive_aux.hpp:44
comparison_fields
how to consider file change during comparison and incremental backup
Definition: archive_aux.hpp:53
std::set< fsa_family > fsa_scope
set of fsa families
Definition: fsa_family.hpp:70
hash_algo
hashing algorithm available
Definition: archive_aux.hpp:63
compression
the different compression algorithm available
Definition: compression.hpp:46
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
the main file of the libdar API definitions
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
entrepot relative parameters
string ent_login
entrepot login
secu_string ent_pass
entrepot password
string ent_host
entrepot hostname
string ent_port
entrepot port
bool auth_from_file
whether ~/.netrc and ~/.ssh files should be considered for credentials
U_I network_retry
libcurl entrepot network retry time
string ent_proto
entrepot protocol
defines how to calculate delta signature block size based of file size to delta sign
all parameters retreived from command-line
bool security_check
whether to signal possible root-kit presence
bool warn_remove_no_match
whether to warn file about to be removed during a restoration, when they to no match the expected typ...
secu_string pass_ref
if not an empty string, use the provided encryption scheme to read the archive of reference
bool filter_unsaved
whether to not list files that are not saved in the archive
bool quiet
whether to display final summary for the operation
U_I compression_level
compression level to use when generating an archive
bool exclude_by_ea
whether inode have to be check against a given EA before backup
bool nodump
whether to ignore files having the "nodump" flag set when performing a backup
string filename
basename of the archive to operate on
bool display_skipped
whether to display skipped files
bool remote_verbose
whether to have verbose output from libcurl
bool beep
whether to ring the terminal upon user interaction request
mask * subtree
filter files for the operation based on path+filename
dirty_behavior dirty
what to do when comes the time to restore a file that is flagged as dirty
bool header_only
whether we just display the header of archives to be read
string * ref_filename
basename of the archive of reference (nullptr => no archive of reference)
bool ignore_unknown_inode
whether to ignore unknown inode types
infinint fixed_date
the data for the snapshot backup
bool delta_diff
whether to save binary diff or whole file's data during a differential backup
bool in_place
in-place restoration of comparison
string aux_execute
command to be run between the slice of the auxiliary archive of reference
bool blind_signatures
whether to ignore signature check failures
bool flat
whether to ignore directory structure when restoring data
U_32 crypto_size
block size by which to cypher data
bool display_treated_only_dir
whether to show treated files's current working directory
infinint delta_sig_min_size
size below which to never calculate delta signatures
U_I multi_threaded_compress
number of compress worker threads (requires libthreadar and per block compression)
bool sequential_read
whether to follow escape sequential marks to achieve a sequential reading of the archive
infinint num_digits
minimum number of decimal for the slice number
bool info_details
whether to show processing messages
string input_pipe
if not an empty string, name of the pipe through which to read data from dar_slave
path * fs_root
filesystem root
hash_algo hash
whether to produce a hash file, and which algoritm to use for that hash
bool decremental
whether to produce a decremental backup (when merging)
ent_params remote
remote entrepot coordinates
operation op
which operation to perform
fsa_scope scope
FSA scope to consider for the operation.
comparison_fields what_to_check
what fields to take into account when comparing/restoring files,
ent_params aux_remote
remote entrepot coordinates for the auxiliary archive
string * aux_filename
basename of the auxiliary archive if reference (nullptr => no auxiliary of reference)
secu_string pass
if not an empty string, encrypt the archive with the given algo:pass string
infinint repeat_byte
archive total maximum amount of byte to waste re-saving changing files
bool unix_sockets
whether to restore unix-sockets
bool alter_atime
whether to reset the atime of file read during backup to their original value (resetting atime does m...
string slice_group
group to set when creating a slice
bool keep_compressed
when merging, whether to not uncompress/re-compress data in the process
bool display_masks
whether to display masks value
hash_algo kdf_hash
hash algo used for key derivation function
mask * compress_mask
which file to compress
bool delta_sig
whether to calculate rsync signature of files
bool not_deleted
whether to ignore deleted files
bool display_finished
whether to display summary (space/compression ratio) for each completed directory
string execute
if not an empty string, the command to execute between slices
bool empty_dir
whether to store skipped directories as empty, whether to avoid restoring directory where no data is ...
bool use_sequential_marks
whether to add escape sequential marks in the archive
bool zeroing_neg_dates
whether to automatically zeroing negative dates while reading inode from filesystem
mask * delta_mask
which file to calculate delta sig when not using the default mask
path * aux_root
where is the auxiliary archive of reference [used for merging but also when creating an archive,...
bool cache_directory_tagging
whether to ignore directory contents where a the cache directory tagging files is found
const crit_action * overwrite
the overwriting policy
string output_pipe
if not an empty string, name of the pipe through which to write orders to dar_slave
bool empty
whether to do a dry-run execution
compression algo
compression algorithm to use when generating an archive
infinint min_compr_size
below which size to never try compressing files
string slice_perm
permission to set when creating a slice
string ea_name_for_exclusion
EA name to use for file exclusion, or empty string for the default EA name.
string slice_user
user to set when creating a slice
archive_options_listing_shell::listformat list_mode
type of listing to follow
infinint ref_num_digits
minimum number of decimal for the slice number of the archive of reference
deque< string > same_fs_incl
optional list of path to filesystems to stick to (for backup operation)
path * ref_root
where is the archive of reference
secu_string aux_pass
crypto to use for the auxiliary archive
bool only_deleted
whether to only consider deleted files
infinint repeat_count
number of time to try saving a file if it changes at the time it is read for backup
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
bool warn_over
whether to warn before overwriting files or slices
bool list_ea
whether to list Extended Attribute of files
string backup_hook_execute
which command to execute as backup hook
modified_data_detection modet
how to detect that a file has changed since the archive of reference was done
bool no_compare_symlink_date
whether to report difference in dates of symlinks while diffing an archive with filesystem
U_I multi_threaded_crypto
number of crypto worker threads (requires libthreadar)
bool snapshot
whether to perform a snapshot backup
bool allow_over
whether to allow slice overwriting
infinint first_file_size
sice of the first slice to create
bool sizes_in_bytes
whether to display sizes in bytes of to the larges unit (Mo, Go, To,...)
mask * backup_hook_mask
which file have to considered for backup hook
infinint aux_num_digits
minimum number of decimal for the slice number of the auxiliary archive of reference
delta_sig_block_size delta_sig_len
block len to used for delta signature computation
path * sauv_root
where is the archive to operate on (create, read, etc.)
U_I compression_block_size
compression block size (0 for legacy compression method)
infinint pause
whether to pause between slices
U_32 aux_crypto_size
block size by which to cypher/uncypher data to/from the auxiliary archive of reference
infinint iteration_count
iteration count used when creating/isolating/merging an encrypted archive (key derivation)
bool lax
whether to activate the last chance recovery mode (use with caution!)
string user_comment
user comment to add to the archive
string ignored_as_symlink
column separated list of absolute paths of links to follow rather to record as such
infinint hourshift
consider equal two dates that have an integer hour of difference equal or less than hourshift
mask * ea_mask
which EA to work on
infinint file_size
size of the slices to create (except the first)
deque< string > same_fs_excl
optional list of path to filesystems to not consider (for backup operation)
ent_params ref_remote
remote entrepot coordinates for archive of reference
string execute_ref
if not an empty string, the command to execute between slices of the archive of reference
U_32 crypto_size_ref
block size by which to uncypher data from the archive of reference
bool same_fs
whether to stick to a same filesystem
mask * selection
filter files for the operation based on filename only
vector< string > signatories
list of email's key to use to sign the archive
bool display_treated
whether to show treated files
bool furtive_read_mode
whether to use the furtive read mode