]> git.sur5r.net Git - bacula/bacula/commitdiff
Add Matt Howard's FileSet conversion script
authorKern Sibbald <kern@sibbald.com>
Sat, 19 Mar 2005 14:12:16 +0000 (14:12 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 19 Mar 2005 14:12:16 +0000 (14:12 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1893 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/examples/conf/fileset_convert.pl [new file with mode: 0755]

diff --git a/bacula/examples/conf/fileset_convert.pl b/bacula/examples/conf/fileset_convert.pl
new file mode 100755 (executable)
index 0000000..f39a00d
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+#
+# A nice little script written by Matt Howard that will
+#  convert old style Bacula FileSets into the new style.
+#
+#   fileset_convert.pl bacula-dir.conf >output-file 
+#
+use warnings;
+use strict;
+
+my $in;
+$in .= $_ while (<>);
+
+sub options {
+    return "Options { ".join('; ',split(/\s+/, shift)) . " } ";
+}
+
+sub file_lines {
+    return join($/, map {"    File = $_"} split(/\n\s*/, shift));
+}
+$in =~ s/Include\s*=\s*((?:\w+=\w+\s+)*){\s*((?:.*?\n)+?)\s*}/
+  "Include { " . 
+  ( $1 ? options($1) : '' ) . "\n" .
+  file_lines($2) .
+  "\n  }\n" /eg;
+
+$in =~ s/Exclude\s*=\s*{\s*((?:.*?\n)+?)\s*}/
+  "Exclude {\n" . file_lines($1) . "\n  }\n"/eg;
+
+print $in;