summaryrefslogtreecommitdiff
blob: 1e9ea220ebf5e4fca063ea0599d49506a01123cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
Index: flexbackup
===================================================================
--- flexbackup	(.../tags/flexbackup-1.2.1-r5)	(revision 784)
+++ flexbackup	(.../trunk)	(revision 784)
@@ -1301,8 +1301,8 @@
 	$cmd .= "$::unz";
     }
     $cmd .= "(";
-    $cmd .= "mkdir -p $::device ; ";
-    $cmd .= "cd $::device ; ";
+    $cmd .= "mkdir -p \"$::device\" ; ";
+    $cmd .= "cd \"$::device\" ; ";
     $cmd .= "$::path{cpio} -i ";
     $cmd .= "-m ";
     $cmd .= "-d ";
@@ -1351,9 +1351,8 @@
 
     # Have to take leading './' off to make rsync's include/exclude work right
     $cmd .= " | $::path{sed} -e \"s/\\.\\///g\" | ";
-
     $cmd .= "$::path{rsync} ";
-    $cmd .= "--include-from=- --exclude=* ";
+    $cmd .= "--files-from=- ";
     $cmd .= "--archive ";
     $cmd .= "$::rsync_verb_flag ";
     $cmd .= "--delete --delete-excluded ";
@@ -1368,7 +1367,7 @@
 	    $cmd .= "$remote:";
 	}
     }
-    $cmd .= "$dir/ $::device";
+    $cmd .= "\"$dir/\" \"$::device\"";
 
     push(@cmds, $cmd);
 
@@ -1658,7 +1657,9 @@
     my $tmpfile = "$cfg::tmpdir/ar.$PROCESS_ID";
     my $remove = '';
 
-    &log("| NOTE: ar archives will not descend directories");
+    &log("| NOTE: ar archives will not recurse into subdirectories,");
+    &log("|       which makes them inappropriate for most backups.");
+    &log("|       Be sure this is what you want.");
 
     if (defined($remote) and ($level != 0)) {
 	my $time = &get_last_date($label, $level, 'numeric');
@@ -1682,11 +1683,13 @@
     $cmd = "cd \"$dir\" && ";
     $cmd .= &file_list_cmd( $dir, $stamp, 'newline', $level, $remote, '-maxdepth 1 ! -type d');
     $cmd .= "> $filelist; ";
+    # Escape any spaces in filenames. 
+    $cmd .= "$::path{sed} -i -e 's/ /\\\\ /g' $filelist; ";
 
     $cmd .= "$::path{ar} rc";
     $cmd .= "$::ar_verb_flag ";
     $cmd .= "$tmpfile ";
-    $cmd .= "`$::path{cat} $filelist`";
+    $cmd .= "\@$filelist ";
     $cmd .= "; $::path{cat} $tmpfile $::z";
 
     # Buffer both sides if remote
@@ -1800,12 +1803,9 @@
 
     $cmd = "cd \"$dir\" && ";
     $cmd .= &file_list_cmd( $dir, $stamp, 'newline', $level, $remote);
-    $cmd .= "> $filelist; ";
-
-    $cmd .= "$::path{lha} a";
+    $cmd .= " | $::path{lha} a";
     $cmd .= "$::lha_verb_flag ";
     $cmd .= "$tmpfile ";
-    $cmd .= "`$::path{cat} $filelist`";
     $cmd .= "; $::path{cat} $tmpfile $::z";
 
     # Buffer both sides if remote
@@ -2766,6 +2766,7 @@
     $::path{'dd'} = &checkinpath('dd');
     $::path{'printf'} = &checkinpath('printf');
     $::path{'mkdir'} = &checkinpath('mkdir');
+	$::path{'sed'} = &checkinpath('sed');
 
     push(@::remoteprogs,($::path{'touch'},$::path{'rm'},$::path{'find'},$::path{'printf'},$::path{'mkdir'}));
 
@@ -4894,9 +4895,9 @@
 			$rex .= '\)"';
 		}
 		# Show what the darn thing is constructing for prune expressions.
-		&log("| \"find\" regex for pruning is:");
-		&log("|     $rex");
-		&line();
+        (my $temp = $rex) =~ s/\\([()|])/$1/g;
+		&log("| \"find\" regex for pruning (shell escaping omitted for clarity) is:");
+		&log("|     $temp");
 		$cmd .= '-regex ' . $rex . ' -prune -o ';
     } else {
 		# Show what the darn thing is constructing for prune expressions.
@@ -4906,6 +4907,7 @@
 		# don't have permissions on and are running as non-root)
 		$cmd .= "-depth ";
     }
+    &line();
 
     $cmd .= "$::mountpoint_flag ";
     $cmd .= "! -type s ";
@@ -5301,12 +5303,14 @@
 	print $::msg "| Checking '$cfg::buffer' on this machine... ";
 	$pipecmd = "sh $tmp_script ";
     } else {
+	$pipecmd = 
+        "$::remoteshell $host '$::path{mkdir} -p $cfg::tmpdir'; " .
+        "cat $tmp_script | ($::remoteshell $host 'cat > $tmp_script; " .
+        "sh $tmp_script; rm -rf $cfg::tmpdir')";
 	print $::msg "| Checking '$cfg::buffer' on host $host... ";
-	$pipecmd =  "$::remoteshell $host '$::path{mkdir} -p $cfg::tmpdir'; cat $tmp_script | ($::remoteshell $host 'cat > $tmp_script; sh $tmp_script; rm -rf $cfg::tmpdir')";
     }
 
     if (!defined($::debug)) {
-
 	open(PIPE,"$pipecmd |") || die;
 
 	$explicit_success = 0;
Index: flexbackup.conf
===================================================================
--- flexbackup.conf	(.../tags/flexbackup-1.2.1-r5)	(revision 784)
+++ flexbackup.conf	(.../trunk)	(revision 784)
@@ -12,19 +12,27 @@
 
 # Configure backup "sets".
 # Not needed if you use "-dir <dir>" to backup one tree at a time.
-# Each set is a simple space-separated list of filesystems
-# Remote filesystems should denoted as 'host:dir'
-# You can use anything (other than 'all') as set names
-#
-# Example:
-#  $set{'set1'} = "/home /usr";
-#  $set{'set2'} = "/dir3 machine2:/dir4 machine3:/dir5";
+# Each set is a simple space-separated list of filesystems.  Remote filesystems
+# should denoted as 'host:dir'.  If the filesystem name (local or remote)
+# contains spaces, then it should be enclosed in its entirety in double quotes.
+# Multiple quoted filesystems included in a set should be space separated just
+# like unquoted filesystem.  The Perl '.' string concatenation operator can be
+# used to split excessively long lines.
+#
+# You can use anything (other than 'all') as set names.
+#
+# Examples:
+#  $set{'set1'} = '/home /usr';
+#  $set{'set2'} = '/dir3 machine2:/dir4 machine3:/dir5';
+#  $set{'set3'} =
+#      '"/mnt/winmachine1/Documents and Settings" ' .
+#      '"/mnt/winmachine1/Program Files"';
 #
 # "-set all" will back up all defined sets. If you are doing a full backup
 # using tapes, each "set" will go onto a different tape and you will be
 # prompted for tape change in between.
 #
-$set{'backup'} = "/home";
+$set{'backup'} = '/home';
 
 # Subtree pruning
 # A space-separated list of directories to prune from each backup.
@@ -42,7 +50,7 @@
 # start with "./".  To be helpful, FlexBackup packages each space-separated
 # prune directory as follows.  If you have a prune list like this
 #
-#     $prune{'/somedir'} = "one two three";
+#     $prune{'/somedir'} = 'one two three';
 #
 # then, the constructed -regex argument to "find" looks like this
 #
@@ -54,31 +62,38 @@
 # terms that match the current base directory in the set you're backing
 # up.  For example, if your backup set definition looks like this
 #
-#     $set{'daily'} = "/home /root /var /usr";
+#     $set{'daily'} = '/home /root /var /usr';
 #
 # and you want to do some exclusions in "/home" and "/var" (but not the other
 # directories), you must set up a prune list for those two directories 
 # separately.  For example, to exclude bert's and ernie's home directories plus
 # /var/tmp, you would need the following:
 #
-#     $prune{'/home'} = "bert ernie";
-#     $prune{'/var'}  = "tmp";
+#     $prune{'/home'} = 'bert ernie';
+#     $prune{'/var'}  = 'tmp';
 #
 # In particular, combining these *does not* work.  For example, this
 #
-#     $prune{'/'} = "home/bert home/ernie var/tmp";
+#     $prune{'/'} = 'home/bert home/ernie var/tmp';
 #
 # doesn't work, unless, of course, your backup set is backing up "/", 
 # which our example is not.
 #
+# Like the $set configuration item, special handling is required for
+# directories with spaces in them.  Double quotes should surround pruning
+# targets but not the key.  Example:
+#
+#     $prune{'/mnt/winmachine1/Documents and Settings'} =
+#         '"user1/Local Settings/Temp" user2';
+#
 # Many other complex and abstruse variations are possible.  Here's one 
 # interesting corner case.  If you want to preserve a directory but none of its
 # contents, you can do it.  Picking on ernie from our previous example, preserve
 # only his home directory:
 #
-#     $prune{'/home'} = "ernie/.*";
+#     $prune{'/home'} = 'ernie/.*';
 #
-$prune{'/'} = "tmp proc";
+$prune{'/'} = 'tmp proc';
 
 # Compression
 $compress = 'gzip'; # one of false/gzip/bzip2/lzop/zip/compress/hardware/lzma
Index: flexbackup.conf.5
===================================================================
--- flexbackup.conf.5	(.../tags/flexbackup-1.2.1-r5)	(revision 784)
+++ flexbackup.conf.5	(.../trunk)	(revision 784)
@@ -24,25 +24,51 @@
 .TP
 \fB$set{\fI'tag'\fR}\fR = \fI'/dir'\fR;
 Configure backup \(dqsets\(dq. Not needed if \(dq-dir <dir>\(dq is used to
-backup one tree at a time.  Each set is a simple space-separated list of
-filesystems/directories. Remote filesystems should be denoted as
-\(dqhost:directory\(dq.  You can use anything (other than \fI'all'\fR) as set
-names. Using \(dq-set all\(dq will back up all defined sets. If you are doing
-a full backup using tapes, each \(dqset\(dq will go onto a different tape and
-you will be prompted for tape change in between. Examples:
+backup one tree at a time.
+Each set is a simple space-separated list of filesystems/directories.
+Remote filesystems should be denoted as \(dqhost:directory\(dq.
+You can use anything (other than \fI'all'\fR) as set names.
+Using \(dq-set all\(dq will back up all defined sets.
+If you are doing a full backup using tapes, each \(dqset\(dq will go onto a
+different tape and you will be prompted for tape change in between.
+Examples:
 .RS
 .PP
 \fB$set{\fI'set1'\fI}\fR = \fI'/home /usr'\fR;
 .br
 \fB$set{\fI'set2'\fI}\fR = \fI'/dir3 machine2:/dir4 machine3:/dir5'\fR;
+.br
+.PP
+Directories (local or remote) with spaces in their names should be enclosed in
+their entirety in double quotes.
+Multiple quoted directories included in a set should be space separated just
+like unquoted directories.
+The Perl '.' string concatenation operator can be used to split excessively
+long sets.
+Example:
+.PP
+\fB$set{\fI'set3'\fI}\fR = \fI
+    '\(dq/mnt/winmachine1/Documents and Settings\(dq ' .
+    '\(dq/mnt/winmachine1/Program Files\(dq';\fR
 .RE
 .TP
 \fB$prune{\fI'/'\fR}\fR = \fI'tmp proc'\fR;
 Configure subtree pruning. A space-separated list of directories to prune from
 each backup. Key is a filesystem/directory or \(dqhost:directory\(dq spec as
-outlined above. Regular expressions allowed (not shell-type wildcards!). There
-is additional explanation (and a lot of examples) in the provided configuration
-file.
+outlined above. Regular expressions allowed (not shell-type wildcards!).
+.RS
+.PP
+Like the \fB$set\fR configuration item, special handling is required for
+directories with spaces in them.  Double quotes should surround pruning targets
+but not the key.  Example:
+.PP
+\fB$prune{\fI'/mnt/winmachine1/Documents and Settings'\fI}\fR = 
+    \fI'\(dquser1/Local Settings/Temp\(dq user2'\fR;
+.br
+.PP
+There are lots of examples and additional explanation in the provided sample
+configuration file.
+.RE
 .TP
 \fB$compress\fR = \fI'false|gzip|bzip2|lzop|zip|compress|hardware'\fR;
 .TQ
@@ -207,7 +233,7 @@
 .RS
 .TP
 If GNU \fBtar\fR is called \fB\(dqgtar\(dq\fR on your system:
-\fB$path{'tar'} = 'gtar';
+\fB$path{'tar'} = 'gtar';\fR
 .TP
 Or it can be used to \fB\(dqsudo\(dq\fR certain commands:
 \fB$path{\fI'find'\fR}\fR = \fI'sudo find'\fR;
@@ -304,3 +330,6 @@
 Written by Edwin Huffstutler (edwinh@computer.org)
 .SH "SEE ALSO"
 \fBflexbackup\fR(1)
+.\" Local Variables:
+.\" mode: nroff
+.\" End: