Hello,

On 3/6/2006 9:57 PM, Dave Dmytriw - NetCetera wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Arno - I apologize for not mentioning your previous input in my fist
list message.  Not an excuse - just that the coffee had not kicked in
yet.  As you know, I appreciate your interest in this.

No worries- I don't think this is something to apologize for. However, I can understand the coffee problem ;-)

Arno Lehmann wrote:

http://www.biostat.wisc.edu/~annis/creations/period.py.html


More important than the text returned is the status code the script
exits with.


ah - I see - my lack of programming intelligence is becoming more clear...

Try using sys.exit(1) instead of simply writing the "1" and things
should work... at least, using a bash script, I can prevent jobs from
running.

Here is the relevant bits from my bacula-dir.conf:

Job {
 Name = "TESTER"
 Type = Backup
 RunBeforeJob = "/etc/bacula/period.py"


That script would be very useful to see...


I just put the default period.py referenced on

http://www.biostat.wisc.edu/~annis/creations/period.py.html

into /etc/bacula and called it.



 Client = testlet-fd
 FileSet = "Full Set"
 Schedule = "WeeklyCycle"
 Storage = DDS-3
 Messages = Standard
 Pool = Default
 Write Bootstrap = "/var/bacula/NightlySave.bsr"
 Max Start Delay = 22h
}

and from the log:
06-Mar 09:51 testlet-dir: No prior Full backup Job record found.
06-Mar 09:51 testlet-dir: No prior or suitable Full backup found. Doing
FULL backup.
06-Mar 09:51 testlet-dir: RunBefore: 1


... and here, some message like
"04-Mar 08:20 goblin-dir: DracheStd.2006-03-04_08.20.00 Fatal error:
RunBeforeJob error: ERR=Child exited with code 1" should be reported.


Yes, I agree. A message that clearly indicates the failure was caused by
a Holiday match would be helpful.

06-Mar 09:51 testlet-dir: Start Backup JobId 6,
Job=TESTER.2006-03-06_09.51.28
06-Mar 09:51 testlet-sd: Job TESTER.2006-03-06_09.51.28 waiting. Cannot
find any appendable volumes.
Please use the "label"  command to create a new Volume for:
   Storage:      "DDS-3" (/dev/nst0)
   Media type:   DDS-3
   Pool:         Default

The RunBefore returns a 1 - but the job progresses.

I am sure there is a much more elegant way to integrate this python
script into the new bacula python framework - but i am certainly not the
guy to try that ... :)

Any thoughts on the best way to do this is greatly appreciated.


One simple line of code should be enough... perhaps two, if you also
count the "import sys"...


It took me a bit longer - but after thinking about it more I have come
up with the following

I'm sorry I didn't post a complete script - I must have misunderstood how fluent you were eith scripting of all kinds. Sorry, I might have saved you an hour or so...

RunBeforeJob = "/etc/bacula/holiday_check.sh"

where holiday_check.sh looks like this:

#! /usr/bin/python

from period import is_holiday, in_period
import sys
if is_holiday(holidays="/etc/bacula/holidays"):
        print "Holiday Detected: Job not run."
        sys.exit(1)
print "Holiday check passes."
sys.exit(0)

Great. That should work.

and the following appears in the Bacula logs:

06-Mar 13:52 testlet-dir: No prior Full backup Job record found.
06-Mar 13:52 testlet-dir: No prior or suitable Full backup found. Doing
FULL backup.
06-Mar 13:52 testlet-dir: RunBefore: Holiday Detected: Job not run.
06-Mar 13:52 testlet-dir: TESTER.2006-03-06_13.52.21 Fatal error:
RunBeforeJob error: ERR=Child exited with code 1

Bingo ! - Tx Arno.

I still think there is a way to integrate this into the Python framework
in Bacula, but again, I am not the guy to do it.

Sorry to hear that as I'm rather curious how to use python efficiently in Bacula but couldn't find the time to play with it. Well, I'm sure someday someone will :-)

Arno

Dave


Arno

Dave

--
Dave Dmytriw
Principal, NetCetera Solutions Inc.
Calgary, AB
403-703-1399
[EMAIL PROTECTED]
http://www.netcetera-solutions.com
"It's about using NetWorks, Etc..."



- -------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


- --
Dave Dmytriw
Principal, NetCetera Solutions Inc.
Calgary, AB
403-703-1399
[EMAIL PROTECTED]
http://www.netcetera-solutions.com
"It's about using NetWorks, Etc..."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEDKIhDcivrcMaKcIRAnAAAJ0cON9TwTWljtye+rQYB2kDbfSiCgCfaOPM
QDhaGcnr2Wj9xe8+0sNWO0Q=
=5CMj
-----END PGP SIGNATURE-----



--
IT-Service Lehmann                    [EMAIL PROTECTED]
Arno Lehmann                  http://www.its-lehmann.de


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to