Re: [Bacula-users] auto labeling with python

2007-12-05 Thread Jason Joines
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#SECTION00356.
>  
> 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 10 
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
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] auto labeling with python

2007-12-03 Thread Rich
On 2007.11.30. 18:10, 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 

well, bad news for you. python seems to be the one who will go away.
labelformat variable expansion also is supposed to disappear at some 
point, but in the end it was suggested to simply use labelformat for now 
and deal with any potential changes in future.

> 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.

currently i am using the following labelformat value :
Label Format = 
"${Pool}_${Job}-${Level}-${Year}.${Month:p/2/0/r}.${Day:p/2/0/r}-${Hour:p/2/0/r}.${Minute:p/2/0/r}"

it should be possible to get out of it and bacula manual the desired 
format for you.

>  I started with the sample director startup script and the 
> documentation at 
> http://www.bacula.org/dev-manual/Python_Scripting.html#SECTION00356.
>  
> 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
> =
-- 
  Rich

-
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
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


[Bacula-users] auto labeling with python

2007-11-30 Thread Jason Joines
 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#SECTION00356.
 
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
=


-
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
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users