--- a/ftbackup Mon Apr 11 15:38:22 2011 +0200
+++ b/ftbackup Mon Apr 11 17:20:37 2011 +0200
@@ -3,7 +3,6 @@
use warnings;
use 5.10.0;
-use IO::File;
use File::Basename;
use Net::FTP;
use Perl6::Slurp;
@@ -33,6 +32,7 @@
my $opt_force = 0;
my $opt_label = "daily";
my $opt_config = "";
+my $opt_dumpdates = "/var/lib/dumpdates";
sub get_configs(@);
sub get_candidates();
@@ -46,7 +46,8 @@
my %CONFIG = (
FTP_DIR => "backup/<LABEL>/<HOSTNAME>",
FTP_PASSIVE => 1,
- FULL_CYCLE => 7, # not used yet
+ FULL_CYCLE => 7,
+ COMPRESSION_LEVEL => 6,
);
MAIN: {
@@ -62,6 +63,7 @@
"m|man" => sub { pod2usage(-exit => 0, -verbose => 3) },
"C|config=s" => sub { @CONFIGS = ($_[1]) },
"V|version" => sub { print "$ME: $VERSION\n"; exit 0 },
+ "D|dumpdates=s" => \$opt_dumpdates,
) or pod2usage;
my %cf = (%CONFIG, get_configs(@CONFIGS));
@@ -206,7 +208,9 @@
### START
__HEAD
- exec "dump -$opt_level -L $label -f- -u -z6 $dev->{dump}"
+
+
+ exec "dump -$opt_level -L $label -f- -u -z$cf{COMPRESSION_LEVEL} $dev->{dump}"
. "| openssl enc -pass env:key -salt -blowfish";
die "Can't exec dumper\n";
};
@@ -221,6 +225,16 @@
}
$dev->{cleanup}->() if $dev->{cleanup};
verbose "Done.\n";
+
+ # fix the dumpdates
+ if ($opt_dumpdates) {
+ open(my $f, "+<", $opt_dumpdates) or die "Can't open $opt_dumpdates: $!\n";
+ $_ = join "", <$f>;
+ s/^$dev->{dump}\s/$dev->{rdev} /mg;
+ seek($f, 0, 0);
+ truncate($f, 0);
+ print $f $_;
+ }
}
}
@@ -298,7 +312,7 @@
# FIXME: should check the containing directories too!
};
- my $f = new IO::File $_ or die "Can't open $_: $!\n";
+ open(my $f, $_) or die "Can't open $_: $!\n";
my %h = map { split /\s*=\s*/, $_, 2 } grep { !/^\s*#/ and /=/ } <$f>;
map { chomp } values %h;
%r = (%r, %h);
@@ -382,6 +396,10 @@
=over
+=item B<-D>|B<--dumpdates> I<file>
+
+Update the I<file> as dumpdates file. (default: /var/lib/dumpdates)
+
=item B<-d>|B<--debug> [I<item>]
Enables debugging for the specified items (comma separated).
@@ -397,7 +415,7 @@
=item B<output>
-The output is not sent via FTP but to stdoud. Beware!
+The output is not sent via FTP but to stdout. Beware!
=back
@@ -446,6 +464,7 @@
FTP_DIR = "backup/<LABEL>/<HOSTNAME>"
FTP_PASSIVE = 1
FULL_CYCLE = 7
+ COMPRESSION_LEVEL = 6
=head2 F<.netrc>
--- a/ftbackup.conf.example Mon Apr 11 15:38:22 2011 +0200
+++ b/ftbackup.conf.example Mon Apr 11 17:20:37 2011 +0200
@@ -15,3 +15,7 @@
# if we need passive mode for file transfer
# FTP_PASSIVE = 1
+
+# Do we need compression? Unfortunately currently only
+# global
+# COMPRESSION_LEVEL = 6