r11668@llin: dpavlin | 2005-12-13 20:08:40 +0100
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Tue, 13 Dec 2005 18:08:50 +0000 (18:08 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Tue, 13 Dec 2005 18:08:50 +0000 (18:08 +0000)
 much much nicer output (actually readable)

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@270 8392b6e1-25fa-0310-8288-cc32f8e212ea

Makefile
bin/BackupPC_incPartsUpdate

index e59522c..3e684ae 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,7 @@ tar: test
        sudo -u backuppc /data/backuppc/bin/BackupPC_tarIncCreate -h llin -s /etc -n 10 -v -f -d
 
 inc: test
-       sudo -u backuppc /data/backuppc/bin/BackupPC_incPartsUpdate -c -d
+       sudo -u backuppc /data/backuppc/bin/BackupPC_incPartsUpdate -c -v
        
 burn: test
        sudo /data/backuppc/bin/BackupPC_burnArchiveCLI
index 2d536aa..6dd87b8 100755 (executable)
@@ -100,6 +100,9 @@ sub get_backup_id($$$) {
 sub tar_check($$$$) {
        my ($host,$share,$num,$filename) = @_;
 
+       my $t = time();
+       print curr_time, " check $host:$share#$num -> $filename";
+
        sub check_part {
                my ($host, $share, $num, $part_nr, $tar_size, $size, $md5, $items) = @_;
                my $backup_id = get_backup_id($host, $share, $num);
@@ -119,10 +122,10 @@ sub tar_check($$$$) {
                                $row->{md5} eq $md5 &&
                                $row->{items} == $items
                        );
-                       print STDERR "# deleting invalid row $row->{id}\n" if ($opt{d});
+                       print ", deleting invalid backup_parts $row->{id}";
                        $dbh->do(qq{ delete from backup_parts where id = $row->{id} });
                }
-               print STDERR "# inserting new backup_part row\n";
+               print ", inserting new";
                my $sth_insert = $dbh->prepare(qq{
                        insert into backup_parts (
                                backup_id,
@@ -138,16 +141,10 @@ sub tar_check($$$$) {
                $dbh->commit;
        }
 
-       if ($debug) {
-               print STDERR " {{ CHECK: ${host}:${share}#${num} and $filename";
-       } else {
-               print " check $filename";
-       }
-
        my @tar_parts;
 
        if (-d "$tar_dir/$filename") {
-               print STDERR " multi-part" if ($opt{d});
+               print ", multi-part";
                opendir(my $dir, "$tar_dir/$filename") || die "can't readdir $tar_dir/$filename: $!";
                @tar_parts = map { my $p = $_; $p =~ s#^#${filename}/#; $p } grep { !/^\./ && !/md5/ && -f "$tar_dir/$filename/$_" } readdir($dir);
                closedir($dir);
@@ -166,7 +163,7 @@ sub tar_check($$$$) {
 
        foreach my $tarfilename (@tar_parts) {
 
-               print STDERR " $tarfilename" if ($debug);
+               print "\n\t- $tarfilename";
 
                my $size = (stat( "$tar_dir/$tarfilename" ))[7] || die "can't stat $tar_dir/$tarfilename";
 
@@ -176,6 +173,8 @@ sub tar_check($$$$) {
                        last;
                }
 
+               print ", $size bytes";
+
                my $path = "$tar_dir/$tarfilename";
 
                open(my $fh, "gzip -cd $tar_dir/$tarfilename |") or die "can't open $tar_dir/$tarfilename: $!";
@@ -191,13 +190,15 @@ sub tar_check($$$$) {
                        $tar_size += $entry->size;
 
                        if ($tar_size > $Conf{MaxArchiveFileSize}) {
-                               print STDERR " part too big $tar_size > $Conf{MaxArchiveFileSize} }}" if ($debug);
+                               print ", part $tarfilename is too big $tar_size > $Conf{MaxArchiveFileSize}\n";
                                $same = 0;
                                last;
                        }
 
                }
 
+               print ", $items items";
+
                #
                # check if md5 exists, and if not, create one
                #
@@ -207,6 +208,8 @@ sub tar_check($$$$) {
                if (! -e $md5_path || -z $md5_path) {
                        print ", creating md5";
                        system( $bin->{md5sum} . " $path > $md5_path") == 0 or die "can't create md5 $path: $!";
+               } else {
+                       ## FIXME check if existing md5 is valid
                }
 
                my $md5 = read_file( $md5_path ) || die "can't read md5sum file $md5_path: $!";
@@ -227,9 +230,7 @@ sub tar_check($$$$) {
        return $same unless($same);
 
        @tar_files = sort @tar_files;
-       print STDERR " ",($#tar_files + 1), " files" if ($debug);
-
-       print STDERR ", database" if ($debug);
+       print "\n\t",($#tar_files + 1), " tar files";
 
        my $sth = $dbh->prepare(qq{
                SELECT path,type
@@ -248,13 +249,13 @@ sub tar_check($$$$) {
                push @db_files, $path;
        }
 
-       print STDERR " ",($#db_files + 1), " files, diff" if ($debug);
+       print " ",($#db_files + 1), " database files, diff";
 
        @db_files = sort @db_files;
 
        if ($#tar_files != $#db_files) {
                $same = 0;
-               print STDERR " NUMBER" if ($debug);
+               print " NUMBER";
        } else {
                my $diff = Algorithm::Diff->new(\@tar_files, \@db_files);
                while ( $diff->Next() ) {
@@ -265,8 +266,8 @@ sub tar_check($$$$) {
                }
        }
 
-       print " ",($same ? 'ok' : 'DIFFERENT');
-       print STDERR " }} " if ($debug);
+       print " ",($same ? 'ok' : 'DIFFERENT'),
+               ", dur: ",fmt_time(time() - $t), "\n";
 
        return $same;
 }