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