Disk ARchive  2.5.13
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-2052 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <vector>
32 #include "infinint.hpp"
33 #include "compressor.hpp"
34 #include "mask.hpp"
35 #include "path.hpp"
36 #include "catalogue.hpp"
37 #include "archive.hpp"
38 #include "criterium.hpp"
39 #include "shell_interaction.hpp"
40 
41 using namespace std;
42 using namespace libdar;
43 
46 
47 enum operation { noop, extract, create, diff, test, listing, isolate, merging, version_or_help };
48  // noop stands for no-operation. get_args() never returns such value,
49  // it is just necessary within the command_line module
50 
51 enum dirty_behavior { dirtyb_ignore, dirtyb_warn, dirtyb_ok };
52 
53  // all parameters retreived from command-line
54 struct line_param
55 {
56  operation op; //< which operation to perform
57  path * fs_root; //< filesystem root
58  path * sauv_root; //< where is the archive to operate on (create, read, etc.)
59  string filename; //< basename of the archive to operate on
60  path * ref_root; //< where is the archive of reference
61  string * ref_filename; //< basename of the archive of reference (nullptr => no archive of reference)
62  infinint file_size; //< size of the slices to create (except the first)
63  infinint first_file_size; //< sice of the first slice to create
64  mask * selection; //< filter files for the operation based on filename only
65  mask * subtree; //< filter files for the operation based on path+filename
66  bool allow_over; //< whether to allow slice overwriting
67  bool warn_over; //< whether to warn before overwriting files or slices
68  bool info_details; //< whether to show processing messages
69  bool display_treated; //< whether to show treated files
70  bool display_treated_only_dir;//< whether to show treated files's current working directory
71  bool display_skipped; //< whether to display skipped files
72  bool display_finished; //< whether to display summary (space/compression ratio) for each completed directory
73  compression algo; //< compression algorithm to use when generating an archive
74  U_I compression_level; //< compression level to use when generating an archive
75  infinint pause; //< whether to pause between slices
76  bool beep; //< whether to ring the terminal upon user interaction request
77  bool empty_dir; //< whether to store skipped directories as empty, whether to avoid restoring directory where no data is to be restored
78  mask * ea_mask; //< which EA to work on
79  string input_pipe; //< if not an empty string, name of the pipe through which to read data from dar_slave
80  string output_pipe; //< if not an empty string, name of the pipe through which to write orders to dar_slave
81  cat_inode::comparison_fields what_to_check; //< what fields to take into account when comparing/restoring files,
82  string execute; //< if not an empty string, the command to execute between slices
83  string execute_ref; //< if not an empty string, the command to execute between slices of the archive of reference
84  secu_string pass; //< if not an empty string, encrypt the archive with the given algo:pass string
85  vector<string> signatories; //< list of email's key to use to sign the archive
86  bool blind_signatures; //< whether to ignore signature check failures
87  secu_string pass_ref; //< if not an empty string, use the provided encryption scheme to read the archive of reference
88  mask * compress_mask; //< which file to compress
89  bool flat; //< whether to ignore directory structure when restoring data
90  infinint min_compr_size; //< below which size to never try compressing files
91  bool nodump; //< whether to ignore files having the "nodump" flag set when performing a backup
92  bool exclude_by_ea; //< whether inode have to be check against a given EA before backup
93  string ea_name_for_exclusion; //< EA name to use for file exclusion, or empty string for the default EA name
94  infinint hourshift; //< consider equal two dates that have an integer hour of difference equal or less than hourshift
95  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
96  bool filter_unsaved; //< whether to not list files that are not saved in the archive
97  bool empty; //< whether to do a dry-run execution
98  bool alter_atime; //< whether to reset the atime of file read during backup to their original value (resetting atime does modify ctime)
99  bool same_fs; //< whether to stick to a same filesystem
100  bool snapshot; //< whether to perform a snapshot backup
101  bool cache_directory_tagging; //< whether to ignore directory contents where a the cache directory tagging files is found
102  U_32 crypto_size; //< block size by which to cypher data
103  U_32 crypto_size_ref; //< block size by which to uncypher data from the archive of reference
104  archive_options_listing::listformat list_mode; //< type of listing to follow
105  path * aux_root; //< where is the auxiliary archive of reference [used for merging but also when creating an archive, for the on-fly isolation]
106  string * aux_filename; //< basename of the auxiliary archive if reference (nullptr => no auxiliary of reference)
107  secu_string aux_pass; //< crypto to use for the auxiliary archive
108  string aux_execute; //< command to be run between the slice of the auxiliary archive of reference
109  U_32 aux_crypto_size; //< block size by which to cypher/uncypher data to/from the auxiliary archive of reference
110  bool keep_compressed; //< when merging, whether to not uncompress/re-compress data in the process
111  infinint fixed_date; //< the data for the snapshot backup
112  bool quiet; //< whether to display final summary for the operation
113  const crit_action * overwrite;//< the overwriting policy
114  string slice_perm; //< permission to set when creating a slice
115  string slice_user; //< user to set when creating a slice
116  string slice_group; //< group to set when creating a slice
117  infinint repeat_count; //< number of time to try saving a file if it changes at the time it is read for backup
118  infinint repeat_byte; //< archive total maximum amount of byte to waste re-saving changing files
119  bool decremental; //< whether to produce a decremental backup (when merging)
120  bool furtive_read_mode; //< whether to use the furtive read mode
121  bool lax; //< whether to activate the last chance recovery mode (use with caution!)
122  bool use_sequential_marks; //< whether to add escape sequential marks in the archive
123  bool sequential_read; //< whether to follow escape sequential marks to achieve a sequential reading of the archive
124  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
125  dirty_behavior dirty; //< what to do when comes the time to restore a file that is flagged as dirty
126  bool security_check; //< whether to signal possible root-kit presence
127  string user_comment; //< user comment to add to the archive
128  hash_algo hash; //< whether to produce a hash file, and which algoritm to use for that hash
129  infinint num_digits; //< minimum number of decimal for the slice number
130  infinint ref_num_digits; //< minimum number of decimal for the slice number of the archive of reference
131  infinint aux_num_digits; //< minimum number of decimal for the slice number of the auxiliary archive of reference
132  bool only_deleted; //< whether to only consider deleted files
133  bool not_deleted; //< whether to ignore deleted files
134  mask * backup_hook_mask; //< which file have to considered for backup hook
135  string backup_hook_execute; //< which command to execute as backup hook
136  bool list_ea; //< whether to list Extended Attribute of files
137  bool ignore_unknown_inode; //< whether to ignore unknown inode types
138  bool no_compare_symlink_date; //< whether to report difference in dates of symlinks while diffing an archive with filesystem
139  fsa_scope scope; //< FSA scope to consider for the operation
140  bool multi_threaded; //< allows libdar to use multiple threads (requires libthreadar)
141  bool sizes_in_bytes; //< whether to display sizes in bytes of to the larges unit (Mo, Go, To,...)
142  bool header_only; //< whether we just display the header of archives to be read
143  bool zeroing_neg_dates; //< whether to automatically zeroing negative dates while reading inode from filesystem
144 
145  // constructor for line_param
146  line_param()
147  {
148  fs_root= nullptr;
149  sauv_root = nullptr;
150  ref_root = nullptr;
151  selection = nullptr;
152  subtree = nullptr;
153  ref_filename = nullptr;
154  ea_mask = nullptr;
155  compress_mask = nullptr;
156  aux_root = nullptr;
157  aux_filename = nullptr;
158  overwrite = nullptr;
159  backup_hook_mask = nullptr;
160  };
161 
162  // destructor for line_param
163  ~line_param()
164  {
165  if(fs_root != nullptr)
166  delete fs_root;
167  if(sauv_root != nullptr)
168  delete sauv_root;
169  if(ref_root != nullptr)
170  delete ref_root;
171  if(selection != nullptr)
172  delete selection;
173  if(subtree != nullptr)
174  delete subtree;
175  if(ref_filename != nullptr)
176  delete ref_filename;
177  if(ea_mask != nullptr)
178  delete ea_mask;
179  if(compress_mask != nullptr)
180  delete compress_mask;
181  if(aux_root != nullptr)
182  delete aux_root;
183  if(aux_filename != nullptr)
184  delete aux_filename;
185  if(overwrite != nullptr)
186  delete overwrite;
187  if(backup_hook_mask != nullptr)
188  delete backup_hook_mask;
189  };
190 };
191 
193 
194 extern bool get_args(shell_interaction & dialog,
195  const char *home,
196  const vector<string> & dar_dcf_path,
197  const vector<string> & dar_duc_path,
198  S_I argc,
199  char * const argv[],
200  line_param & param);
201 
203 
204 #if HAVE_GETOPT_LONG
205 const struct option *get_long_opt();
206 #endif
207 
208 const char *get_short_opt();
209 #endif
contains classes that let the user define the policy for overwriting files
the generic class, parent of all masks
Definition: mask.hpp:62
the archive class is defined in this module
STL namespace.
here is the definition of the path classthe path class handle path and provide several operation on t...
listformat
defines the way archive listing is done:
the global action for overwriting
Definition: criterium.hpp:77
user_interaction class for command_line tools
switch module to limitint (32 ou 64 bits integers) or infinint
here lies a collection of mask classes
class secu_string
Definition: secu_string.hpp:57
compression
the different compression algorithm available
Definition: compressor.hpp:43
bool nodump()
returns whether nodump flag support has been activated at compilation time
compression engine implementation
bool get_args(shell_interaction &dialog, const char *home, const vector< string > &dar_dcf_path, const vector< 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 arbitrary large positive integer class
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
comparison_fields
flag used to only consider certain fields when comparing/restoring inodes
Definition: cat_inode.hpp:60
here is defined the many classed which is build of the catalogue
the class path is here to manipulate paths in the Unix notation: using&#39;/&#39;
Definition: path.hpp:50