From abadf3407a014581f88f84eb8d61920bbc1cb390 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 19 Mar 2005 14:12:16 +0000 Subject: [PATCH] Add Matt Howard's FileSet conversion script git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1893 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/examples/conf/fileset_convert.pl | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 bacula/examples/conf/fileset_convert.pl 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; -- 2.39.5