From: Kern Sibbald Date: Sat, 19 Mar 2005 14:12:16 +0000 (+0000) Subject: Add Matt Howard's FileSet conversion script X-Git-Tag: Release-1.38.0~589 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=abadf3407a014581f88f84eb8d61920bbc1cb390;p=bacula%2Fbacula Add Matt Howard's FileSet conversion script git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1893 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/examples/conf/fileset_convert.pl b/bacula/examples/conf/fileset_convert.pl new file mode 100755 index 0000000000..f39a00d2ba --- /dev/null +++ b/bacula/examples/conf/fileset_convert.pl @@ -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;