<?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"
	>

<channel>
	<title>Lior Gradstein's Blog &#187; software</title>
	<atom:link href="http://www.gradstein.info/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gradstein.info</link>
	<description></description>
	<pubDate>Mon, 29 Sep 2008 12:39:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Synchronization methods of a file with Puppet</title>
		<link>http://www.gradstein.info/ruby/synchronization-methods-of-a-file-with-puppet/</link>
		<comments>http://www.gradstein.info/ruby/synchronization-methods-of-a-file-with-puppet/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 12:39:32 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[puppet]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[cluster]]></category>

		<category><![CDATA[management]]></category>

		<category><![CDATA[reductivelabs]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/?p=37</guid>
		<description><![CDATA[Usually, to synchronize a file with remote hosts, using puppet, one would use the following pattern:
file &#123; &#34;/etc/init.d/pvfs2-server&#34;:
&#160; &#160; &#160; owner =&#62; root, group =&#62; root, 
&#160; &#160; &#160; mode =&#62; 755, 
&#160; &#160; &#160; source =&#62; &#34;puppet:///files/pvfs2-server&#34; &#160; &#160;
&#125;
(using &#8220;source&#8221; to copy data as-is, and using &#8220;template(&#8221;filename&#8221;) to use a template structure as data).
Or, [...]]]></description>
			<content:encoded><![CDATA[<p>Usually, to synchronize a file with remote hosts, using <a href="http://reductivelabs.com/trac/puppet/" class="liexternal">puppet</a>, one would use the following pattern:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;/etc/init.d/pvfs2-server&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; owner =&gt; root, group =&gt; root, <br />
&nbsp; &nbsp; &nbsp; mode =&gt; <span style="color: #ff4500;">755</span>, <br />
&nbsp; &nbsp; &nbsp; source =&gt; <span style="color: #483d8b;">&quot;puppet:///files/pvfs2-server&quot;</span> &nbsp; &nbsp;<br />
<span style="color: black;">&#125;</span></div>
<p>(using &#8220;source&#8221; to copy data as-is, and using &#8220;template(&#8221;filename&#8221;) to use a template structure as data).</p>
<p>Or, if one wishes to directly set the content of the target file:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;/etc/init.d/pvfs2-server&quot;</span>:<br />
&nbsp; &nbsp;owner =&gt; root, group =&gt; root, <br />
&nbsp; &nbsp;mode =&gt; <span style="color: #ff4500;">755</span>, <br />
&nbsp; &nbsp;source =&gt; <span style="color: #483d8b;">&quot;puppet:///files/pvfs2-server&quot;</span> &nbsp; &nbsp;<br />
<span style="color: black;">&#125;</span></div>
<p>Please note that on the first line, for example &#8216;file { &#8220;/etc/mpd.conf&#8221;:&#8217;), the &#8220;/etc/mpd.conf&#8221; is a merge of two functionalities/concepts: Usually, the syntax is clear and simple:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span> mon_fichier_mpd_conf:<br />
&nbsp; &nbsp; &nbsp;path =&gt; <span style="color: #483d8b;">&quot;/etc/mpd.conf&quot;</span>,<br />
&nbsp; &nbsp; &nbsp;<span style="color: black;">&#91;</span>&#8230;<span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span></div>
<p>The first line is about the resource description. Its goal is to be able to reference to it a little later from another resources (Notify[], etc.). By putting directly the file path and name (I think it&#8217;s identified as a filename and not as a description because there are quotes, or maybe it&#8217;s because it begins with a slash?) you mege the &#8220;path&#8221; attribute with its description.<br />
On the other end, we&#8217;ll not be able to reference to it later, if you need to.</p>
<p>You may also need to synchronize a file that is not present in the repository (puppet:///files/*). That usually happens, for example, when that file is regenerated by an external program or an external action (like /etc/passwd).</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #008000;">file</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;/etc/passwd&quot;</span>:<br />
&nbsp; &nbsp; &nbsp;owner =&gt; root, group =&gt; root, mode =&gt; <span style="color: #ff4500;">644</span>,<br />
&nbsp; &nbsp; &nbsp;content =&gt; <span style="color: #008000;">file</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/etc/passwd&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: black;">&#125;</span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/ruby/synchronization-methods-of-a-file-with-puppet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to automatically run a script after inserting a USB device on Ubuntu?</title>
		<link>http://www.gradstein.info/hardware/how-to-automatically-run-a-script-after-inserting-a-usb-device-on-ubuntu/</link>
		<comments>http://www.gradstein.info/hardware/how-to-automatically-run-a-script-after-inserting-a-usb-device-on-ubuntu/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 21:32:01 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[hardware]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[automatic]]></category>

		<category><![CDATA[download]]></category>

		<category><![CDATA[hotplug]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[mount]]></category>

		<category><![CDATA[photos]]></category>

		<category><![CDATA[program]]></category>

		<category><![CDATA[run]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[ubuntu]]></category>

		<category><![CDATA[udev]]></category>

		<category><![CDATA[usb]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/?p=35</guid>
		<description><![CDATA[Here&#8217;s the setup: you have a computer which has a SD port (small memory cards, mostly used in cameras, phones, etc.). You want to get all of your photos from that card automatically as soon as you insert your card (may be a USB key as well), that is, run a script which will search [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the setup: you have a computer which has a SD port (small memory cards, mostly used in cameras, phones, etc.). You want to get all of your photos from that card automatically as soon as you insert your card (may be a USB key as well), that is, run a script which will search for all of your photos, and copy them to a local directory.</p>
<p><span id="more-35"></span></p>
<p>I know, some programs already do this, but they require Xwindow and some <a href="http://f-spot.org/Main_Page" class="liexternal">ugly Gnome</a>/KDE app. What we&#8217;re doing here is a minimal setup, using the least memory.</p>
<p>Normally, on a normal Unix system you would use the included device detection mechanism, which is <a href="http://linux-hotplug.sourceforge.net/" title="Linux Hotplug project" class="liexternal">hotplug</a>. But on Ubuntu (at least <em>Gutsy</em> and <em>Hardy</em>), the de-facto/required way is by using <strong>udev</strong>, which is an event based system, using rules to fire new events/mount/symlink or run programs according to some patterns defined as &#8220;rules&#8221;.</p>
<p>So, the first thing to do is to identify your device according to USB events. udevinfo is your friend. So, after looking at the output of dmesg, you&#8217;ll see your USB device is available on some sd* device.</p>
<p>So run:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"> udevinfo -a -p &nbsp;/<span style="color: #dc143c;">sys</span>/block/sda<br />
<span style="color: black;">&#40;</span>replace sda with you device<span style="color: black;">&#41;</span></div>
<p>You will get a list of &#8220;blocks&#8221; representing each layer of drivers. For example:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">root@sleek:/etc/udev/rules.<span style="color: black;">d</span><span style="color: #808080; font-style: italic;"># udevinfo -a -p /sys/block/sda/</span></p>
<p>looking at device <span style="color: #483d8b;">&#8216;/block/sda&#8217;</span>:<br />
KERNEL==<span style="color: #483d8b;">&quot;sda&quot;</span><br />
SUBSYSTEM==<span style="color: #483d8b;">&quot;block&quot;</span><br />
DRIVER==<span style="color: #483d8b;">&quot;&quot;</span><br />
ATTR<span style="color: black;">&#123;</span><span style="color: #dc143c;">stat</span><span style="color: black;">&#125;</span>==<span style="color: #483d8b;">&quot; &nbsp;229567 &nbsp; &nbsp;[...] 456048 &nbsp;3697068&quot;</span><br />
ATTR<span style="color: black;">&#123;</span>size<span style="color: black;">&#125;</span>==<span style="color: #483d8b;">&quot;488397168&quot;</span><br />
ATTR<span style="color: black;">&#123;</span>removable<span style="color: black;">&#125;</span>==<span style="color: #483d8b;">&quot;0&quot;</span><br />
ATTR<span style="color: black;">&#123;</span><span style="color: #008000;">range</span><span style="color: black;">&#125;</span>==<span style="color: #483d8b;">&quot;16&quot;</span><br />
ATTR<span style="color: black;">&#123;</span>dev<span style="color: black;">&#125;</span>==<span style="color: #483d8b;">&quot;8:0&quot;</span></p>
<p>looking at parent device <span style="color: #483d8b;">&#8216;/devices/pci0000:00/00[...]:<br />
KERNELS==&quot;2:0:0:0&quot;<br />
SUBSYSTEMS==&quot;scsi&quot;<br />
DRIVERS==&quot;sd&quot;<br />
ATTRS{ioerr_cnt}==&quot;0&#215;0&quot;<br />
ATTRS{iodone_cnt}==&quot;0xcc26b&quot;<br />
ATTRS{iorequest_cnt}==&quot;0xcc26c&quot;<br />
ATTRS{iocounterbits}==&quot;32&quot;<br />
ATTRS{timeout}==&quot;30&quot;<br />
ATTRS{state}==&quot;running&quot;<br />
ATTRS{rev}==&quot;3.AA&quot;<br />
ATTRS{model}==&quot;ST3250310AS &nbsp; &nbsp; &quot;<br />
ATTRS{vendor}==&quot;ATA &nbsp; &nbsp; &quot;</span></div>
<p>These are in fact attributes that you can use in your rule to filter the devices. So for example,<br />
to run a shell script when a SCSI device is detected which has a size of 1GB, I&#8217;ll use the following line:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">KERNEL==<span style="color: #483d8b;">&quot;sd?1&quot;</span>, ATTRS<span style="color: black;">&#123;</span>size<span style="color: black;">&#125;</span>==<span style="color: #483d8b;">&quot;1999872&quot;</span>, RUN+=<span style="color: #483d8b;">&quot;/usr/local/bin/recup_usb.sh&quot;</span></div>
<p>This line is to be put in a new file in /etc/udev/rules.d, named something like 91-backuptousbdrivetrigger.rules. It&#8217;s better to put the file at the end of the rules (the &#8220;91&#8243;), as not to disturb other module loadings.</p>
<p>The content of the recup_usb.sh file can be:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #808080; font-style: italic;">#!/bin/bash</span></p>
<p><span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#91;</span> <span style="color: #483d8b;">&quot;${ACTION}&quot;</span> = <span style="color: #483d8b;">&quot;add&quot;</span> <span style="color: black;">&#93;</span>; then<br />
&nbsp; &nbsp;rm -rf /tmp/x<br />
&nbsp; &nbsp;mkdir /tmp/x<br />
&nbsp; &nbsp;mount -t vfat /dev/sdc1 /tmp/x<br />
&nbsp; &nbsp;find /tmp/x -name <span style="color: #483d8b;">&quot;*jpg&quot;</span> -<span style="color: #ff7700;font-weight:bold;">exec</span> /usr/bin/rsync -avz <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> &nbsp;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /home/foobar/Pictures/Incoming/`date +%Y-%m-%d`/ \;<br />
&nbsp; &nbsp;umount /tmp/x<br />
fi</div>
<p><em>(yes, I know this code is dirty, I should have used mktemp, but you get the point&#8230;)</em><br />
Don&#8217;t forget to chmod +x the shell script and reload the configuration with:</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">udevcontrol reload_rules</div>
<p>For more detailed information about writing udev rules, take a look at the<a href="http://reactivated.net/writing_udev_rules.html" class="liexternal"> official documentation</a>, or <a href="http://tlug.dnho.net/?q=smeserver_udev_automated_backups" class="liexternal">another&#8217;s detailed information</a> about doing the same thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/hardware/how-to-automatically-run-a-script-after-inserting-a-usb-device-on-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to recover from Cyrus when you have some DB errors</title>
		<link>http://www.gradstein.info/software/how-to-recover-from-cyrus-when-you-have-some-db-errors/</link>
		<comments>http://www.gradstein.info/software/how-to-recover-from-cyrus-when-you-have-some-db-errors/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 12:31:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[software]]></category>

	<!-- AutoMeta Start -->
	<category>panic</category>
	<category>fatal</category>
	<category>region</category>
	<category>error</category>
	<category>detected</category>
	<category>reading</category>
	<category>var lib cyrus db skipstamp</category>
	<category>the</category>
	<category>objective  this</category>
	<category>document</category>
	<category>explains</category>
	<category>messages</category>
	<category>dberror</category>
	<category>dberror</category>
	<category>db4</category>
	<category>assuming</category>
	<category>the</category>
	<category>worst</category>
	<category>recover</category>
	<category>a</category>
	<category>mix</category>
	<category>methods</category>
	<category>and</category>
	<category>tips</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/software/how-to-recover-from-cyrus-when-you-have-some-db-errors/</guid>
		<description><![CDATA[I&#8217;ll try to explain some methods and tips on how to recover from a mix in db libraries, or from messages like:

DBERROR: reading /var/lib/cyrus/db/skipstamp, assuming the worst: No such file or directory
DBERROR db4: PANIC: fatal region error detected; run recovery
DBERROR: critical database situation


Structure of Cyrus database
The database is split in two parts. The first part [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll try to explain some methods and tips on how to recover from a mix in db libraries, or from messages like:</p>
<ul>
<li>DBERROR: reading /var/lib/cyrus/db/skipstamp, assuming the worst: No such file or directory</li>
<li>DBERROR db4: PANIC: fatal region error detected; run recovery</li>
<li>DBERROR: critical database situation</li>
</ul>
<p><span id="more-28"></span></p>
<h3>Structure of Cyrus database</h3>
<p>The database is split in two parts. The first part is the real database, normally located in
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">/var/lib/cyrus</div>
<p>:</p>
<p class="code">mail:/usr/src/cyrus-imapd-2.2.10# cd /var/lib/cyrus<br />
mail:/var/lib/cyrus# ll<br />
total 60<br />
-rw&#8212;&#8212;-  1 cyrus mail   144 Feb 20 16:54 annotations.db<br />
drwxr-xr-x  2 cyrus mail  4096 Feb 20 16:54 db<br />
drwx&#8212;&#8212;  2 cyrus mail  4096 Feb 20 16:54 db.backup1<br />
-rw&#8212;&#8212;-  1 cyrus mail  8192 Feb 20 16:54 deliver.db<br />
drwxr-xr-x  2 cyrus mail  4096 Feb 20 16:46 log<br />
-rw&#8212;&#8212;-  1 cyrus mail 11644 Feb 20 16:54 mailboxes.db<br />
drwxr-xr-x  2 cyrus mail  4096 Feb 20 16:46 msg<br />
drwxr-xr-x  2 cyrus mail  4096 Feb 20 17:15 proc<br />
drwxr-xr-x  2 cyrus mail  4096 Feb 20 16:46 ptclient<br />
drwxr-xr-x  2 cyrus mail  4096 Feb 20 16:55 socket<br />
-rw&#8212;&#8212;-  1 cyrus mail  8192 Feb 20 16:54 tls_sessions.db</p>
<p>In fact, in this part, the only (and most important in all of Cyrus) useful thing, is the mailboxes.db file. Everything else can be reconstructed from nothing.</p>
<p>The second part is containing all the emails and filters (sieve). Usually they are located in
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">/var/spool/cyrus/</div>
<p>. I advise you to make a recursive backup of these two directories in case something goes really wrong.</p>
<h3>Possible problems, and their solution</h3>
<p>Look for all the instances of cyrus executables you may have. The easiest for this is to use the
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">locate</div>
<p> command (after updating the database with updatedb). Try
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">locate ctl_mboxlist</div>
<p> for example. For each of the files run a
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">ldd ctl_mboxlist</div>
<p> (or on any other executable from cyrus):</p>
<p class="code">
mail:/var/lib/cyrus# ldd /usr/cyrus/bin/ctl_mboxlist<br />
        libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0&#215;4001c000)<br />
        libssl.so.0.9.7 => /usr/lib/i686/cmov/libssl.so.0.9.7 (0&#215;40031000)<br />
        libcrypto.so.0.9.7 => /usr/lib/i686/cmov/libcrypto.so.0.9.7 (0&#215;40063000)<br />
        libresolv.so.2 => /lib/tls/libresolv.so.2 (0&#215;40162000)<br />
        libdb-4.2.so => /usr/lib/libdb-4.2.so (0&#215;40174000)<br />
        libc.so.6 => /lib/tls/libc.so.6 (0&#215;4024a000)<br />
        libdl.so.2 => /lib/tls/libdl.so.2 (0&#215;4037f000)<br />
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0&#215;40000000)</p>
<p>The important thing is to have all of your executables linked with the same libdb version (here it is
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">libdb<span style="color: #ff4500;">-4.2</span>.<span style="color: black;">so</span></div>
<p>).</p>
<p>The first thing to do, before anything else, is to verify the integrity of your Cyrus installation. Stop the Cyrus daemon, and restart it, and look at the logs. Many times, I see errors about daemons not found. For example, one of them (
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">ctl_cyrusdb</div>
<p>) is supposed to recover automatically from a db crash, but when you have the following error:</p>
<p class="code">Feb 20 07:13:48 mail master[11873]: about to exec /usr/sbin/ctl_cyrusdb<br />
Feb 20 07:13:48 mail master[11873]: can&#8217;t exec /usr/sbin/ctl_cyrusdb on schedule: No such file or directory<br />
Feb 20 07:13:48 mail master[10665]: process 11873 exited, status 71</p>
<p>You can be sure, you&#8217;ll have a disaster next.</p>
<p>One problem is that the database has not been generated with the same libdb version as the current one. To correct this, change your user to the cyrus admin user (normally cyrus) and execute the following command, while looking at the syslog files:</p>
<p class="code">root@mail:/tmp# su - cyrus<br />
cyrus@mail:/var/lib/cyrus$ ctl_cyrusdb -r</p>
<p>It is normal you don&#8217;t get any output from the command. The output goes into SYSLOG. When the recovery is successful, you&#8217;ll have this:</p>
<p class="code">Feb 20 16:00:07 mail ctl_cyrusdb[31041]: recovering cyrus databases<br />
Feb 20 16:00:07 mail ctl_cyrusdb[31041]: skiplist: recovered /var/lib/cyrus/mailboxes.db (124 records, 13092 bytes) in 0 seconds<br />
Feb 20 16:00:08 mail ctl_cyrusdb[31041]: skiplist: recovered /var/lib/cyrus/annotations.db (0 records, 144 bytes) in 1 second<br />
Feb 20 16:00:08 mail ctl_cyrusdb[31041]: done recovering cyrus databases</p>
<p>Here, you see that Cyrus found 124 mailboxes.</p>
<p>If this is not sufficient, you&#8217;ll have to delete the
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">/var/lib/cyrus/db/*</div>
<p> contents and re-run
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">ctl_cyrusdb</div>
<p>.</p>
<p>If this is still not sufficient, you&#8217;ll have to do the extreme: Rebuild all the
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">/var/lib/cyrus</div>
<p> directory. To do this, first try to get a &#8220;text&#8221; version (export) of the mailboxes.db. If you manage to do this, you&#8217;ve saved. To export the list of mailboxes, do the following, as user cyrus:</p>
<p class="code">cyrus@mail:/tmp$ /usr/cyrus/bin/ctl_mboxlist -d -f /tmp/mailboxes.db</p>
<p>This will output the users/mailboxes to stdout. Verify that it&#8217;s ok, then re-run the command and redirect the output to a file:</p>
<p class="code">cyrus@mail:/tmp$ /usr/cyrus/bin/ctl_mboxlist -d -f /tmp/mailboxes.db > /tmp/mboxlist.txt</p>
<p>Then remove completely the
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">/var/lib/cyrus</div>
<p> directory. Recreate it with the following commands:</p>
<p class="code">root@mail:/tmp# /usr/bin/cyrus/tools/mkimap<br />
root@mail:/tmp# chown -R cyrus:mail /var/lib/cyrus<br />
root@mail:/tmp# /usr/cyrus/bin/reconstruct -r -f user</p>
<p>Here, you&#8217;ll have no output, meaning it found no users. That&#8217;s normal, as we just have a clean new mailboxes.db. If you&#8217;ve run the command reconstruct as root, do forget to immediately change back the roght to the files:</p>
<p class="code">root@mail:/tmp# chown -R cyrus:mail /var/lib/cyrus</p>
<p>Now we just have to rebuild the mailboxes.db file:</p>
<p class="code">root@mail:/tmp# su - cyrus<br />
cyrus@mail:/tmp$ cat /tmp/mboxlist.txt | /usr/cyrus/bin/ctl_mboxlist -u<br />
cyrus@mail:/tmp$ /usr/cyrus/bin/reconstruct -r -f user</p>
<p>Here, you&#8217;ll have a list of the found users in the database.</p>
<p>Now try to start again Cyrus.</p>
<h3>Useful references</h3>
<ul>
<li><a href="http://www.irbs.net/internet/info-cyrus/0411/0412.html" class="liexternal">http://www.irbs.net/internet/info-cyrus/0411/0412.html</a></li>
<li><a href="http://david.codebase.ca/index.cgi/os%20x/cyrus.writeback" class="liexternal">http://david.codebase.ca/index.cgi/os%20x/cyrus.writeback</a></li>
<li><a href="http://www.kalamazoolinux.org/pipermail/members/2004-July/011219.html" class="liexternal">http://www.kalamazoolinux.org/pipermail/members/2004-July/011219.html</a></li>
<li><a href="http://www.afp548.com/article.php?story=20040824063737872" class="liexternal">http://www.afp548.com/article.php?story=20040824063737872</a></li>
<li><a href="http://www.die.net/doc/linux/man/man8/reconstruct.8.html" class="liexternal">http://www.die.net/doc/linux/man/man8/reconstruct.8.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/software/how-to-recover-from-cyrus-when-you-have-some-db-errors/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
