[Dirvish] patch for dirvish, long backups would overlap

John Altstadt john.altstadt at gmail.com
Sun Jan 2 22:13:42 UTC 2011

Hi All,

Here is a patch that I have been using for less than a day. However it has
been tested several times during that period with both artificial and normal
test cases.

The version of dirvish supplied in Ubuntu 9.10 and 10.04 will allow backups
to overlap if it takes longer to backup an image than the interval between
snapshots. There was some traffic in the mailing list back in 2008 regarding
this, but nothing was ever resolved.

This is a simple patch which causes dirvish to exit if there is already a
backup running on the same vault. I considered waiting for the backup to
complete before continuing, but that simply swaps one type of bad behavior
for another by stacking up a series of pending backups in the worst case.
The behavior I chose to implement simply skips a scheduled backup. It has
the added benefit that other backups scheduled via dirvish-runall will run
as before.

The lock_file used contains the PID of the instance of dirvish, so you can
use ps to check against the PID in the file if things seem hung up.

You can also turn off snapshots for any specific vault with the command:
    touch lock_file
in the dirvish directory inside that vault, assuming that there isn't
already a snapshot in progress.

The version of dirvish shipped with Ubuntu 10.04 has this identifier near
the beginning of the file:

#       $Id: dirvish.pl,v 12.0 2004/02/25 02:42:15 jw Exp $  $Name:
Dirvish-1_2 $

The context diff follows:


diff -c dirvish.original dirvish
*** dirvish.original    2008-05-05 10:04:03.000000000 +0200
--- dirvish    2011-01-02 12:03:36.198544979 +0100
*** 456,461 ****
--- 456,473 ----

  if (!$$Options{'no-run'})
+     $lock_file = "$vault/dirvish/lock_file";
+     if (! -f $lock_file)
+     {
+         open(LOCK, "+>", $lock_file) or seppuku 150, "cannot create
+         printf LOCK $$;
+         close(LOCK);
+     }
+     else
+     {
+             seppuku 151, "$lock_file already exists";
+     }
      mkdir "$vault/$image", 0700
          or seppuku 230, "mkdir $vault/$image failed";
      mkdir $destree, 0755;
*** 760,765 ****
--- 772,779 ----

+ unlink($lock_file);
      system ("rm -rf $destree");


I felt it was about time I contributed something back to the community
again. Please feel free to use this patch or criticize it as you see fit. It
works for me.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dirvish.org/pipermail/dirvish/attachments/20110102/5fdc6129/attachment.html 

More information about the Dirvish mailing list