--- a/bin/ftbackup Thu Apr 28 12:48:05 2011 +0200
+++ b/bin/ftbackup Thu Apr 28 17:13:30 2011 +0200
@@ -248,7 +248,7 @@
$ENV{key} = $cf{KEY};
my $dumper = open(my $dump, "-|") or do {
print <<__HEAD;
-#! /bin/bash
+#! /bin/sh
LC_ALL=C
if test -t 1; then
cat <<___
@@ -262,19 +262,28 @@
DEVICE_NO : $dev->{devno}
# For recovery pass everything following the first
-# ^### START to "recover -rf -". Or do one of the following
+# ^#-- START to "recover -rf -". Or do one of the following
# lines:
-# sh <THIS SCRIPT> | restore -rf -
-# sh <(ftpipe <URL>) -pass file:/dev/tty | restore -rf -
+# sh <THIS SCRIPT> | restore -rf -
+# ftpipe <URL> | sh | restore -rf -
+# sh <(ftpipe <URL>) | restore -rf -
+#
+# The tool "ftpipe" can be found at https://keller.schlittermann.de/hg/beta/ftpipe
+# or there about.
___
exit 0
fi
+
+if test -t 0; then input="\$0"
+else input="/dev/fd/0"
+fi
+
while read; do
- test "\$REPLY" = "### START" \\
+ test "\$REPLY" = "#-- START" \\
&& exec openssl enc -d -blowfish "\$@"
-done <"\$0"
-
-### START
+done <\$input
+exit
+#-- START
__HEAD
@@ -287,6 +296,7 @@
};
if ($ftp) {
+ verbose("sending dump to " . $ftp->pwd . "/$file\n");
$ftp->try(put => $dump, $file);
}
else {
@@ -426,12 +436,11 @@
sub update_devnames($$$) {
my ($file, $from, $to) = @_;
- open(my $f, "+>>", $file) or die "Can't open $file: $!\n";
+ open(my $f, "+>>" => $file) or die "Can't open $file: $!\n";
seek($f, 0, 0);
my $_ = join "", <$f>;
s/^$from\s/$to /mg;
truncate($f, 0);
- # fix the dumpdates
print $f $_;
close($f);
}
@@ -559,14 +568,15 @@
push @{$dumps[$+{level}]} => { file => $_, date => $+{date}, stamp => str2time($+{date})};
}
- ### @dumps
# sort the level 0 dumps by date and remove all but the last $keep
# ones.
# if we found level 0 dumps, we remove all level 1+ dumps older than
# the oldest level 0 dump we'll remove
@{$dumps[0]} = sort { $a->{stamp} <=> $b->{stamp} } @{$dumps[0]};
- my @unlink = splice(@{$dumps[0]}, -1, @{$dumps[0]} - $keep);
+
+ ### @dumps
+ my @unlink = splice(@{$dumps[0]}, 0, -$keep);
if ($dumps[1]) {
if (!@{$dumps[0]}) { push @unlink, @{@dumps[1..$#dumps]} }