Disk ARchive  2.4.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 
40 using namespace std;
41 using namespace libdar;
42 
45 
46 enum operation { noop, extract, create, diff, test, listing, isolate, merging, version_or_help };
47  // noop stands for no-operation. get_args() never returns such value,
48  // it is just necessary within the command_line module
49 
50 enum dirty_behavior { dirtyb_ignore, dirtyb_warn, dirtyb_ok };
51 
52  // all parameters retreived from command-line
53 struct line_param
54 {
55  operation op; //< which operation to perform
56  path * fs_root; //< filesystem root
57  path * sauv_root; //< where is the archive to operate on (create, read, etc.)
58  string filename; //< basename of the archive to operate on
59  path * ref_root; //< where is the archive of reference
60  string * ref_filename; //< basename of the archive of reference (NULL => no archive of reference)
61  infinint file_size; //< size of the slices to create (except the first)
62  infinint first_file_size; //< sice of the first slice to create
63  mask * selection; //< filter files for the operation based on filename only
64  mask * subtree; //< filter files for the operation based on path+filename
65  bool allow_over; //< whether to allow slice overwriting
66  bool warn_over; //< whether to warn before overwriting files or slices
67  bool info_details; //< whether to be verbose
68  compression algo; //< compression algorithm to use when generating an archive
69  U_I compression_level; //< compression level to use when generating an archive
70  infinint pause; //< whether to pause between slices
71  bool beep; //< whether to ring the terminal upon user interaction request
72  bool empty_dir; //< whether to store skipped directories as empty, whether to avoid restoring directory where no data is to be restored
73  mask * ea_mask; //< which EA to work on
74  string input_pipe; //< if not an empty string, name of the pipe through which to read data from dar_slave
75  string output_pipe; //< if not an empty string, name of the pipe through which to write orders to dar_slave
76  inode::comparison_fields what_to_check; //< what fields to take into account when comparing/restoring files,
77  string execute; //< if not an empty string, the command to execute between slices
78  string execute_ref; //< if not an empty string, the command to execute between slices of the archive of reference
79  secu_string pass; //< if not an empty string, encrypt the archive with the given algo:pass string
80  secu_string pass_ref; //< if not an empty string, use the provided encryption scheme to read the archive of reference
81  mask * compress_mask; //< which file to compress
82  bool flat; //< whether to ignore directory structure when restoring data
83  infinint min_compr_size; //< below which size to never try compressing files
84  bool nodump; //< whether to ignore files having the "nodump" flag set when performing a backup
85  infinint hourshift; //< consider equal two dates that have an integer hour of difference equal or less than hourshift
86  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
87  bool filter_unsaved; //< whether to not list files that are not saved in the archive
88  bool empty; //< whether to do a dry-run execution
89  bool alter_atime; //< whether to reset the atime of file read during backup to their original value (resetting atime does modify ctime)
90  bool same_fs; //< whether to stick to a same filesystem
91  bool snapshot; //< whether to perform a snapshot backup
92  bool cache_directory_tagging; //< whether to ignore directory contents where a the cache directory tagging files is found
93  U_32 crypto_size; //< block size by which to cypher data
94  U_32 crypto_size_ref; //< block size by which to uncypher data from the archive of reference
95  bool display_skipped; //< whether to display skipped files
96  archive_options_listing::listformat list_mode; //< type of listing to follow
97  path * aux_root; //< where is the auxiliary archive of reference [used for merging but also when creating an archive, for the on-fly isolation]
98  string * aux_filename; //< basename of the auxiliary archive if reference (NULL => no auxiliary of reference)
99  secu_string aux_pass; //< crypto to use for the auxiliary archive
100  string aux_execute; //< command to be run between the slice of the auxiliary archive of reference
101  U_32 aux_crypto_size; //< block size by which to cypher/uncypher data to/from the auxiliary archive of reference
102  bool keep_compressed; //< when merging, whether to not uncompress/re-compress data in the process
103  infinint fixed_date; //< the data for the snapshot backup
104  bool quiet; //< whether to display final summary for the operation
105  const crit_action * overwrite;//< the overwriting policy
106  string slice_perm; //< permission to set when creating a slice
107  string slice_user; //< user to set when creating a slice
108  string slice_group; //< group to set when creating a slice
109  infinint repeat_count; //< number of time to try saving a file if it changes at the time it is read for backup
110  infinint repeat_byte; //< archive total maximum amount of byte to waste re-saving changing files
111  bool decremental; //< whether to produce a decremental backup (when merging)
112  bool furtive_read_mode; //< whether to use the furtive read mode
113  bool lax; //< whether to activate the last chance recovery mode (use with caution!)
114  bool use_sequential_marks; //< whether to add escape sequential marks in the archive
115  bool sequential_read; //< whether to follow escape sequential marks to achieve a sequential reading of the archive
116  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
117  dirty_behavior dirty; //< what to do when comes the time to restore a file that is flagged as dirty
118  bool security_check; //< whether to signal possible root-kit presence
119  string user_comment; //< user comment to add to the archive
120  hash_algo hash; //< whether to produce a hash file, and which algoritm to use for that hash
121  infinint num_digits; //< minimum number of decimal for the slice number
122  infinint ref_num_digits; //< minimum number of decimal for the slice number of the archive of reference
123  infinint aux_num_digits; //< minimum number of decimal for the slice number of the auxiliary archive of reference
124  bool only_deleted; //< whether to only consider deleted files
125  bool not_deleted; //< whether to ignore deleted files
126  mask * backup_hook_mask; //< which file have to considered for backup hook
127  string backup_hook_execute; //< which command to execute as backup hook
128  bool list_ea; //< whether to list Extended Attribute of files
129  bool ignore_unknown_inode; //< whether to ignore unknown inode types
130  bool no_compare_symlink_date; //< whether to report difference in dates of symlinks while diffing an archive with filesystem
131 
132  // constructor for line_param
133  line_param()
134  {
135  fs_root= NULL;
136  sauv_root = NULL;
137  ref_root = NULL;
138  selection = NULL;
139  subtree = NULL;
140  ref_filename = NULL;
141  ea_mask = NULL;
142  compress_mask = NULL;
143  aux_root = NULL;
144  aux_filename = NULL;
145  overwrite = NULL;
146  backup_hook_mask = NULL;
147  };
148 
149  // destructor for line_param
150  ~line_param()
151  {
152  if(fs_root != NULL)
153  delete fs_root;
154  if(sauv_root != NULL)
155  delete sauv_root;
156  if(ref_root != NULL)
157  delete ref_root;
158  if(selection != NULL)
159  delete selection;
160  if(subtree != NULL)
161  delete subtree;
162  if(ref_filename != NULL)
163  delete ref_filename;
164  if(ea_mask != NULL)
165  delete ea_mask;
166  if(compress_mask != NULL)
167  delete compress_mask;
168  if(aux_root != NULL)
169  delete aux_root;
170  if(aux_filename != NULL)
171  delete aux_filename;
172  if(overwrite != NULL)
173  delete overwrite;
174  if(backup_hook_mask != NULL)
175  delete backup_hook_mask;
176  };
177 };
178 
180 
181 extern bool get_args(user_interaction & dialog,
182  const char *home,
183  const vector<string> & dar_dcf_path,
184  const vector<string> & dar_duc_path,
185  S_I argc,
186  char * const argv[],
187  line_param & param);
188 
190 
191 #if HAVE_GETOPT_LONG
192 const struct option *get_long_opt();
193 #endif
194 
195 const char *get_short_opt();
196 #endif
contains classes that let the user define the policy for overwriting files
the generic class, parent of all masks
Definition: mask.hpp:61
the archive class is defined in this module
This is a pure virtual class that is used by libdar when interaction with the user is required...
comparison_fields
flag used to only consider certain fields when comparing/restoring inodes
Definition: catalogue.hpp:209
bool get_args(user_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
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:76
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
the arbitrary large positive integer class
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'/'
Definition: path.hpp:50