r9051@llin: dpavlin | 2006-01-18 16:16:23 +0100
[BackupPC.git] / bin / BackupPC_incPartsUpdate
index 3971f7e..7f7313c 100755 (executable)
@@ -16,6 +16,24 @@ use Archive::Tar::Streamed;
 use Algorithm::Diff;
 use Getopt::Std;
 use File::Slurp;
+use File::Pid;
+
+my $pid_path = abs_path($0);
+$pid_path =~ s/\W+/_/g;
+
+my $pidfile = new File::Pid({
+       file => "/tmp/$pid_path",
+});
+
+if (my $pid = $pidfile->running ) {
+       die "$0 already running: $pid\n";
+} elsif ($pidfile->pid ne $$) {
+       $pidfile->remove;
+       $pidfile = new File::Pid;
+}
+
+print STDERR "$0 using pid ",$pidfile->pid," file ",$pidfile->file,"\n";
+$pidfile->write;
 
 my $bpc = BackupPC::Lib->new || die "can't create BackupPC::Lib";
 my %Conf = $bpc->Conf();
@@ -245,7 +263,7 @@ sub tar_check($$$$) {
 
                # real tar size is bigger because of padding    
                if ($tar_size_inarc > $tar_size) {
-                       print ", size of files in tar bigger than whole tar!\n";
+                       print ", size of files in tar ($tar_size_inarc) bigger than whole tar ($tar_size)!\n";
                        return 0;
                }