Hi All,
We wanted to limit the number of concurrent full backups. It's not
possible to configure it in the configuration file without affecting the
number of concurrent incremental backups. I created a small Python
script to downgrade Full backups to Incremental if more than 2 Full
backups are running.
Not much python scripting examples exist so I attached our script. Feel
free to comment or use it as a starting point for your own scripts.
Cheers,
Bram.
import MySQLdb
class IvSBacula(object):
def __init__(self):
self.conn = MySQLdb.connect (host = "xxxx",
user = "xxx",
passwd = "xxxx",
db = "bacula")
def getCursor(self):
return self.conn.cursor ()
def canRunFull(self):
cursor = self.getCursor()
cursor.execute ("SELECT COUNT(1) FROM Job WHERE Level = 'F' AND JobStatus IN ('R', 'B', 'F', 'S', 'm', 'M', 's', 'j', 'c', 'd', 't', 'p');")
row = cursor.fetchone ()
cursor.close()
return (row[0] < 3)
#
# Bacula Python interface script for the Director
#
# You must import both sys and bacula
import sys, bacula
from IvSBacula import *
# This is the list of Bacula daemon events that you
# can receive.
class BaculaEvents(object):
def __init__(self):
# Called here when a new Bacula Events class is
# is created. Normally not used
noop = 1
def JobStart(self, job):
"""
Called here when a new job is started. If you want
to do anything with the Job, you must register
events you want to receive.
"""
events = JobEvents() # create instance of Job class
events.job = job # save Bacula's job pointer
job.set_events(events) # register events desired
sys.stderr = events # send error output to Bacula
sys.stdout = events # send stdout to Bacula
jobid = job.JobId; client = job.Client
numvols = job.NumVols
job.JobReport="Python Dir JobStart: JobId=%d Client=%s NumVols=%d\n" % (jobid,client,numvols)
# Bacula Job is going to terminate
def JobEnd(self, job):
jobid = job.JobId
client = job.Client
job.JobReport="Python Dir JobEnd output: JobId=%d Status=%s Client=%s.\n" % (jobid, job.JobStatus, client)
# Called here when the Bacula daemon is going to exit
def Exit(self, job):
print "Daemon exiting."
bacula.set_events(BaculaEvents()) # register daemon events desired
"""
There are the Job events that you can receive.
"""
class JobEvents(object):
def __init__(self):
self.ivs = IvSBacula()
def JobInit(self, job):
# Limit number of concurrent full jobs
if (job.Level == "Full"):
if (self.ivs.canRunFull()):
job.JobReport = "IvS: Level FULL"
else:
job.JobLevel = "Incremental"
job.JobReport = "IvS: Level downgraded to Incr (too many full jobs running)"
def JobRun(self, job):
noop = 1
def NewVolume(self, job):
noop = 1
def VolumePurged(self, job):
noop = 1
# Pass output back to Bacula
def write(self, text):
noop = 1
# Open file to be backed up. file is the filename
# NOT YET IMPLEMENTED
def open(self, file):
noop = 1
# NOT YET IMPLEMENTED
def read(self, mem):
noop = 1
# NOT YET IMPLEMENTED
def close(self):
noop = 1
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users