BackupPC-users

Re: [BackupPC-users] How do you set a command to mount nfs backup share?

2008-10-30 00:56:41
Subject: Re: [BackupPC-users] How do you set a command to mount nfs backup share?
From: "Jeffrey J. Kosowsky" <backuppc AT kosowsky DOT org>
To: "backuppc-users AT lists.sourceforge DOT net" <backuppc-users AT lists.sourceforge DOT net>
Date: Thu, 30 Oct 2008 00:54:43 -0400
Craig Barratt wrote at about 17:45:07 -0700 on Sunday, October 26, 2008:
 > Jeffrey writes:
 > 
 > > So, ideally, I am looking for a "hook" to run in advance of any web or
 > > backup operation that needs access to /var/lib/BackupPC.
 > > 
 > > Does such a hook exist?
 > > If not where would be the best place in the code to hook into?
 > 
 > No, there isn't such a hook - BackupPC assumes the pool exists.
 > Almost every program and CGI request will access some data below
 > the pool.
 > 
 > You could try putting some code in the BackupPC::Lib initialization,
 > but you will have to think about what error recovery is appropriate.
 > 
 > Craig

I ended up patching in my routine (BackupPC_mount) in 2 places in the
main BackupPC program.

First, at initial setup before the initial HardlinkTest which would
fail anyway if TopDir were not accessible. If the test fails, then the
error is logged and BackupPC quits.

Second in the main loop. Any failure to mount is again logged. This
main loop placement seems to catch all critical points, including
scheduled backups and the web interface.

Here is a (trivial) patch based on my changes in case anybody else
ever needs to do this.

--- BackupPC.jorig      2008-08-11 12:25:34.000000000 -0400
+++ BackupPC.jnew       2008-10-30 00:49:54.000000000 -0400
@@ -222,6 +222,14 @@
     }
 
     #
+       #JJK: Try to (re)mount TopDir if not mounted...
+       #
+    if (system("/etc/BackupPC/BackupPC_mount > /dev/null 2>&1" ) != 0) {
+               print(LOG $bpc->timeStamp,
+            "BackupPC_mount: Could not mount $TopDir\n");
+       }
+
+    #
     # Check if a timeout has occurred.
     #
     Main_Check_Timeout();
@@ -267,6 +275,12 @@
         exit(1);
     }
 
+    #JJK: Added following check to pre-mount before HardlinkTest
+    if (system("/etc/BackupPC/BackupPC_mount > /dev/null 2>&1" ) != 0) { 
+        print(STDERR $bpc->timeStamp, "BackupPC_mount: Could not mount 
$TopDir. Quitting...\n");
+               exit(1);
+       }
+
     if ( !$bpc->HardlinkTest("$TopDir/pc", "$TopDir/cpool") ) {
         print(STDERR $bpc->timeStamp, "Can't create a test hardlink between a 
file"
                    . " in $TopDir/pc and $TopDir/cpool.  Either these are 
different"

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/