Repair Courier IMAP maildir
A handy little script to repair maildirs.
I stupidly deleted all empty folders in users' homes, realizing too late that it would delete some of the essential new, cur and tmp directories in the maildirs. After that, folders could not be opened anymore. Outlook would say "STATUS failed", and Thunderbird reported "Unable to open this mailbox".
This little script recreated the missing directories:
I stupidly deleted all empty folders in users' homes, realizing too late that it would delete some of the essential new, cur and tmp directories in the maildirs. After that, folders could not be opened anymore. Outlook would say "STATUS failed", and Thunderbird reported "Unable to open this mailbox".
This little script recreated the missing directories:
#!/bin/sh
for M in /home/*/Maildir ; do
echo checking $M
for d in cur new tmp ; do
[ -d "$M/$d" ] || { echo "* Creating $M/$d"; mkdir "$M/$d"; }
chown -c --reference "$M" "$M/$d"
chmod -c 700 "$M/$d"
done
find $M -type f -name maildirfolder | while read ; do
f=`dirname "$REPLY"`
echo " checking $f"
for d in cur new tmp ; do
[ -d "$f/$d" ] || { echo " * Creating $f/$d"; mkdir "$f/$d"; }
chown -c --reference "$f" "$f/$d"
chmod -c 700 "$f/$d"
done
done
done