- removeBurnedArchives is tested - removes tgz's that are burned on two or more DVD...
[BackupPC.git] / bin / BackupPC_removeBurnedArchives
index e9c092f..da45dad 100644 (file)
@@ -4,14 +4,17 @@ no utf8;
 
 use lib "__INSTALLDIR__/lib";
 use DBI;
-
-
+use BackupPC::Lib;
+use BackupPC::SearchLib;
+use Data::Dumper;
 my $bpc = BackupPC::Lib->new || die "can't create BackupPC::Lib";
 my %Conf = $bpc->Conf();
-
-my $dsn = $Conf{searchdsn} || die "need searchdsn in config.pl\n";
-my $user = $Conf{searchuser} || '';
-my $dbh = dbi->connect($dsn, $user, "", { raiseerror => 1, autocommit => 0 });
+my $tar_dir = $Conf{InstallDir}."/".$Conf{GzipTempDir};
+%BackupPC::SearchLib::Conf = %Conf;
+#die(Dumper(\%Conf));
+my $dsn = $Conf{SearchDSN} || die "need searchdsn in config.pl\n";
+my $user = $Conf{SearchUser} || '';
+my $dbh = DBI->connect($dsn, $user, "", { raiseerror => 1, autocommit => 0 });
 my $tar_dir = $Conf{InstallDir}.'/'.$Conf{GzipTempDir};
 my $sql = q{
        SELECT hosts.name AS host, shares.name AS share, backups.num AS num, MAX(archive_burned.copy)
@@ -29,11 +32,15 @@ $sth->execute();
 
 while (my $row = $sth->fetchrow_hashref()) {
        my $filename = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'});
-       my (undef, undef, undef, undef, undef, undef, undef, $fs_size, undef, undef, undef, undef, undef) = stat($filename);
+       
+       $filename .= ".tar.gz";
+       $filename = $tar_dir . "/" . $filename;
+       my $fs_size = stat($filename)[7];
        $totalRemoved += $fs_size;
-       if (system("rm $filename") != 0) {
-               print "ERROR: unable to remove $filename.\n";
-       }
+       print "removing $filename... size: $fs_size\n";
+#      if (system("rm $filename") != 0) {
+#              print "ERROR: unable to remove $filename.\n";
+#      }
 }
 
 print "Finished. Freed $totalRemoved bytes (".($totalRemoved/(1024*1024))."MB\n";