Bacula-users

Re: [Bacula-users] How change the MedId for an exist Volume

2010-12-16 10:50:13
Subject: Re: [Bacula-users] How change the MedId for an exist Volume
From: Bob Hetzel <beh AT case DOT edu>
To: bacula-users AT lists.sourceforge DOT net
Date: Thu, 16 Dec 2010 10:47:32 -0500

> From: Martin Simmons <martin AT lispworks DOT com>

>>>>>> >>>>> On Wed, 15 Dec 2010 08:19:02 -0200, Rodrigo N de Castro Fernandes 
>>>>>> >>>>> said:
>> >
>> > I would like to know how to change the MediaId from a VolumeName.
>> > Just for backup Media/Volume sort organization.
>> >
>> > Can somebody help me? Is it possible? Is it recommended?
> It isn't recommended, but you could do it with some SQL commands if you are
> very careful.
>
> Purge the volume first, otherwise you will need to update the jobmedia table
> as well.  You may need to adjust the SQL sequence that controls the automatic
> numbering of new volumes as well, if you new MediaId is higher.  There may be
> other problems that I haven't though about...
>
> __Martin

I'm not 100% sure what the original poster's goal was but in my case my 
goal was to change how bacula sorts when you do a 'list volumes'.  It sorts 
by default by MediaId which is kinda unhelpful to those of us that use 
actual bar-coded tapes.  The MediaId is generated when the volume is first 
inserted into the catalog, but if the autochanger picks up the tapes in the 
wrong order you're left with that odd sorting.  I tried to update the 
tables directly for a while but eventually I decided it was too big a pain 
to wait for a tape to be Scratch (I presume you meant Prune not Purge, by 
the way).

My solution was to just tweak the query bacula uses so that it sorts on the 
VolumeName field instead.  Unfortunately I'm on vacation so can't dig into 
the code to see what file it was in, but all you have to do is change the 
line where the query ends in something like 'order by MediaId' to use 
something 'order by VolumeName' instead.  I figured that would be a great 
enhancement to the bacula code but didn't know if there were actually some 
people who preferred the MediaId order, perhaps because they're mixing LTO3 
and LTO4 tapes or something, so I didn't bother generating a patch to submit.

    Bob

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users