]> git.sur5r.net Git - bacula/bacula/blob - bacula/examples/conf/fileset_convert.pl
Update kernstodo
[bacula/bacula] / bacula / examples / conf / fileset_convert.pl
1 #!/usr/bin/perl
2 #
3 # A nice little script written by Matt Howard that will
4 #  convert old style Bacula FileSets into the new style.
5 #
6 #   fileset_convert.pl bacula-dir.conf >output-file 
7 #
8 use warnings;
9 use strict;
10
11 my $in;
12 $in .= $_ while (<>);
13
14 sub options {
15     return "Options { ".join('; ',split(/\s+/, shift)) . " } ";
16 }
17
18 sub file_lines {
19     return join($/, map {"    File = $_"} split(/\n\s*/, shift));
20 }
21  
22 $in =~ s/Include\s*=\s*((?:\w+=\w+\s+)*){\s*((?:.*?\n)+?)\s*}/
23   "Include { " . 
24   ( $1 ? options($1) : '' ) . "\n" .
25   file_lines($2) .
26   "\n  }" /eg;
27
28 $in =~ s/Exclude\s*=\s*{\s*}/
29   "Exclude { }"/eg;
30
31 $in =~ s/Exclude\s*=\s*{\s*((?:.*?\n)+?)\s*}/
32   "Exclude {\n" . file_lines($1) . "\n  }"/eg;
33
34 print $in;