Jason Joines wrote:
> I'm using Bacula 2.2.5 and have tried auto labeling with
> LabelFormat but haven't had much luck. I don't know python but since
> LabelFormat is deprecated I thought I'd go ahead and give it a try. My
> goal is to get volume names ( and the corresponding file name on disk,
> I'm backing up to disk ) to be formatted like jobname-date-"two digit
> number of volumes for this job". I've also set the max volume size to 5
> GB. So if I had a job named sivadaily run at 0300 and backup 9 GB I
> would like the resulting two volumes to be sivadaily-20071130fr0300-01
> and sivadaily-20071130fr0300-02.
>
> I started with the sample director startup script and the
> documentation at
> http://www.bacula.org/dev-manual/Python_Scripting.html#SECTION003560000000000000000.
>
> I defined "jobname = job.JobName" and modified job.VolumeName in
> NewVolume() to be 'job.VolumeName="%s-%d" % (jobname, numvol)'. Then I
> ran a test job, cas-testdaily, and got volume autolabeled as 'Labeled
> new Volume "jobname-44"'.
> So I guess definition of jobname didn't work. Also, I'm assuming
> the %s and %d are for string variable and integer variable although a
> bit of googling and python manual reading hasn't verified that.
>
> Any suggestions for how to accomplish what I'm after and
> recommendations for learning the python basics demonstrated in the
> sample script?
>
>
> Jason Joines
> =================================
This within the NewVolume() section got close enough to what I want:
from time import localtime, strftime
rightnow = strftime("%Y%m%d%a%H%M%S", localtime())
thisjob = "%05d" % jobid
job.VolumeName = "%s-%s-%s" % (client, thisjob, rightnow)
I end up with volume names like cas-test-fd-00286-20071205Wed000436
where cas-test-fd is the client, 00286 is the five digit zero padded
version of the job id and 20071205Wed000436 is the
YearMonthDayDayofweekHourMinuteSecond.
So they should sort in a file list like I wanted until I hit 100000
jobs which will be many years in my case, and won't conflict unless the
same job can write 5 GB to one volume in less than 1 s and thus need to
create a new volume in the same second as the previous.
Jason
===========
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Bacula-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users