<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cyberz.org &#187; Bacula</title>
	<atom:link href="http://www.cyberz.org/blog/tag/bacula/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cyberz.org/blog</link>
	<description>Andrea Leofreddi's homepage</description>
	<lastBuildDate>Tue, 10 Aug 2010 17:19:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Bacula mail changer script (aka poor man&#8217;s autoloader)</title>
		<link>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/</link>
		<comments>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 22:16:32 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Bacula]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=24</guid>
		<description><![CDATA[I enjoy Bacula for automated]]></description>
			<content:encoded><![CDATA[<p>I enjoy Bacula for automated home backups on DLT and DDS tape drives. Being used at home there&#8217;s no &#8211; obviously &#8211; big-dollar-company-manager to ask for an autoloader; and when the time of a tape change comes bacula lacks a simple way to request a manual tape change and just hangs up. So I managed to build a fake autoloader shell script, which, using emails, would emulate a real autoloader. This script, which I baptised <em>mail-changer</em>, features:</p>
<ul>
<li>email support</li>
<li>periodic email resend when tape change is needed</li>
<li>tape detection and check (if you&#8217;re supposed to insert tape 4 and you enter 5, the script will kindly refuse the tape, unload it and send a warning email message asking for the right one)</li>
</ul>
<p><span id="more-24"></span>To implement the third point (tape detection and check), it was necessary to extract the tape id from the bacula tape. That can be done looking at the bacula&#8217;s tape header structure:</p>
<p>The first structure stored is called &#8220;Block Header&#8221; and is 24 bytes long:</p>
<pre>   uint32_t CheckSum;                /* Block check sum */
   uint32_t BlockSize;               /* Block byte size including the header */
   uint32_t BlockNumber;             /* Block number */
   char ID[4] = "BB02";              /* Identification and block level */
   uint32_t VolSessionId;            /* Session Id for Job */
   uint32_t VolSessionTime;          /* Session Time for Job */</pre>
<p>Then a &#8220;Record Header&#8221; follows (12 bytes):</p>
<pre>  int32_t FileIndex;   /* File index supplied by File daemon */
  int32_t Stream;      /* Stream number supplied by File daemon */
  uint32_t DataSize;   /* size of following data record in bytes */</pre>
<p>Then a structure which is interesting for us, called &#8220;Volume Label&#8221; follows:</p>
<pre>  char Id[32];              /* Bacula 1.0 Immortal\n */
  uint32_t VerNum;          /* Label version number */
  /* VerNum 11 and greater Bacula 1.27 and later */
  btime_t   label_btime;    /* Time/date tape labeled */
  btime_t   write_btime;    /* Time/date tape first written */
  /* The following are 0 in VerNum 11 and greater */
  float64_t write_date;     /* Date this label written */
  float64_t write_time;     /* Time this label written */
  char VolName[128];        /* Volume name */
  char PrevVolName[128];    /* Previous Volume Name */
  char PoolName[128];       /* Pool name */
  char PoolType[128];       /* Pool type */
  char MediaType[128];      /* Type of this media */
  char HostName[128];       /* Host name of writing computer */
  char LabelProg[32];       /* Label program name */
  char ProgVersion[32];     /* Program version */
  char ProgDate[32];        /* Program build date/time */</pre>
<p>What is really important for us is the VolName field, which is at relative offset +56 from the beginning of the <em>Volume Label</em>. Adding 12 bytes of <em>Record Header</em> and 24 of <em>Block Header</em> makes 92 bytes.</p>
<p>Please note that mail-changer has been developed on Solaris 10 using CSW&#8217;s Bacula, you may need to work a bit to adapt it to your unix.</p>
<p>You can <a title="mail-changer script" href="/projects/mail-changer/mail-changer" target="_blank">download mail-changer here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
