tranfer xferOK to detect errors and run cleanup
[BackupPC.git] / bin / BackupPC_ASA_PostArchive_Update
index e3d022d..1dea094 100755 (executable)
@@ -38,6 +38,7 @@ my ($opt,$usage) = describe_options(
 "%c %o",
 [ 'host|h=s@', "import just host(s)" ],
 [ 'num|n=s@',  "import just backup number(s)" ],
+[ 'ok=n',       "xferOK", { default => 0 } ],
 [ 'check|c',   "check archives on disk and sync", { default => 1 } ],
 [ 'debug|d',   "debug", { default => 1 } ],
 [ 'help',      "show help" ],
@@ -377,7 +378,15 @@ foreach ( 0 .. $#{ $opt->host } ) {
        my $host = $opt->host->[$_];
        my $num  = $opt->num->[$_];
 
-       check_archive $host => $num;
+       if ( ! $opt->ok ) {
+               warn "ERROR $host $num running cleanup";
+               foreach my $path ( glob "$Conf{ArchiveDest}/$host.$num.*" ) {
+                       warn "# rm $path";
+                       unlink $path || die $!;
+               }
+       } else {
+               check_archive $host => $num;
+       }
 
 }