cyrreconstruct and resurrected deleted/moved

Steinar Bang sb at
Tue Feb 14 12:49:46 EST 2006

>>>>> Sebastian Hagedorn <Hagedorn at>:

>>>>> Steinar Bang <sb at>:

>>> So my questions are:
>>> Is there a way short of redoing the Christmas cleanup from an
>>> email client to get back to the state before the massive
>>> delete/move?  Ie. what if I wrote a perl script that unlinked
>>> everything that had more than one hardlink in
>>> /var/spool/cyrus/mail/s/user/myuser/sub/ and then did
>>> cyrreconstruct?

>> That might work, but you're on your own with it ...

Well, now I've tried it, and it (so far) seems to be working.  I wrote
the script /tmp/, which looks like this:

# This script will unlink all files in a directory that has both:
#  - A filename matching the pattern [0-9]+\.
#  - More than one hardlink
opendir(THISDIR,$dirName) || die "Open of $dirName failed!\n";
@files = grep /[0-9]+\./, readdir(THISDIR);

$deletecount = 0;
foreach $file (@files) {
    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file);
    if ($nlink > 1) {
        print "Removing hardlink for $file...";
        print "done!\n";
        $deletecount = $deletecount + 1;
print "$deletecount files deleted\n";

Then I did the following as root on the cyrus server machine: 
 /etc/init.d/cyrus21 stop
 cd /var/spool/cyrus/mail/m/user/myusername/subfolder/
 /bin/su cyrus
 /usr/sbin/cyrreconstruct user.myusername.subfolder
 /etc/init.d/cyrus21 start

Hopefully I won't be bitten at a later stage...:-)

More information about the Info-cyrus mailing list