# Any cyrus-imap guru out there? I broken my imap db...

## nbensa

I was upgrading my server today and after a reboot, cyrus wouldn't start. So I checked the logs:

```
Sep 18 23:05:42 zeddmore master[11385]: setrlimit: Unable to set file descriptors limit to -1: Operation not permitted

Sep 18 23:05:42 zeddmore master[11385]: retrying with 1024 (current max)

Sep 18 23:05:42 zeddmore master[11385]: process started

Sep 18 23:05:42 zeddmore master[11389]: about to exec /usr/lib/cyrus/ctl_cyrusdb

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11389]: DBERROR: db4

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11389]: recovering cyrus databases

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11389]: skiplist: recovered /var/imap/mailboxes.db (106 records, 13796 bytes) in 0 seconds

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11389]: skiplist: recovered /var/imap/annotations.db (0 records, 144 bytes) in 0 seconds

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11389]: DBERROR: db4

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11389]: DBERROR: db4

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11389]: DBERROR: critical database situation

Sep 18 23:05:42 zeddmore master[11385]: process 11389 exited, status 75

Sep 18 23:05:42 zeddmore master[11385]: ready for work

Sep 18 23:05:42 zeddmore master[11413]: about to exec /usr/lib/cyrus/tls_prune

Sep 18 23:05:42 zeddmore master[11414]: about to exec /usr/lib/cyrus/ctl_deliver

Sep 18 23:05:42 zeddmore cyr_expire[11414]: DBERROR : db4

Sep 18 23:05:42 zeddmore cyr_expire[11414]: DBERROR: critical database situation

Sep 18 23:05:42 zeddmore master[11415]: about to exec /usr/lib/cyrus/ctl_cyrusdb

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11415]: DBERROR: db4

Sep 18 23:05:42 zeddmore ctl_cyrusdb[11415]: DBERROR: critical database situation

Sep 18 23:05:42 zeddmore master[11385]: process 11414 exited, status 75

Sep 18 23:05:42 zeddmore master[11385]: process 11415 exited, status 75

Sep 18 23:05:42 zeddmore tls_prune[11413]: DBERROR : db4

Sep 18 23:05:42 zeddmore tls_prune[11413]: DBERROR: critical database situation

Sep 18 23:05:42 zeddmore master[11385]: process 11413 exited, status 75

Sep 18 23:05:52 zeddmore master[11385]: exiting on SIGTERM/SIGINT

```

Between the upgraded packages I can remember openssl and affected packages depending on it. This included removing lib{ssl,crypto}*0.9.7. If you need emerge.log, I can post it.

I really have no idea how to recover from this or if it is possible at all so I'll be wide-open to any suggestions you may have  :Smile: 

Many thanks in advance,

Norberto

----------

## Janne Pikkarainen

First, BACKUP YOUR CURRENT /var/imap. 

Then

1. Figure out what is your current version of BerkeleyDB installed: for example with emerge -pv db

2. Stop Cyrus.

3. cd /var/imap/db

4. dbX.Y_recover (where X is the major and Y the minor version of BerkeleyDB version: for example for BDB 4.1 you would run db4.1_recover)

5. Pray for help.

6. Start Cyrus.

7. See if it works.

----------

## nbensa

Thanks Janne. I've tried that before but it didn't fix anything. Finally, I did:

```
rm /var/imap/*.db

rm /var/imap/db*/*

```

... and everything is working  :Very Happy: 

----------

## cyclohexan

Hi,

I had the same problem.

db4.3_recover didn't work, but after deleting the db files and restarting cyrus, the db4 error in the logfile disappeared. (Thank you, nbensa.)

However, my mail client cannot login to the user's IMAP mailbox any more. (Authentication failed.)

I don't remember the password, because it was stored in my mail client, but it should work however.

1. What could be the reason why the authentication fails?

2. How can I change a user's Cyrus-IMAP-password?

----------

## nbensa

saslpasswd2

----------

## cyclohexan

Thanks.

saslpasswd2 showed no users. Perhaps the information is lost while deleting the db files?

So I created a new password for the user jan using saslpasswd2 jan.

Now my mail client (Thunderbird) says: 

```
The current command did not succeed. The mail server responded: Mailbox does not exist.
```

The last 2 lines of /var/log/everything/current say:

```
May  9 01:14:35 [imap] auxpropfunc error invalid parameter supplied_

May  9 01:14:50 [imap] login: localhost [127.0.0.1] jan plaintext User logged in
```

ls -la /var/spool/imap/j/jan/ says:

```
total 12

drwx------ 2 cyrus mail 144 Sep  3  2005 .

drwxr-x--- 4 cyrus mail 144 May  7 19:15 ..

-rw------- 1 cyrus mail   4 Sep  3  2005 cyrus.cache

-rw------- 1 cyrus mail 146 Sep  3  2005 cyrus.header

-rw------- 1 cyrus mail  76 Sep  3  2005 cyrus.index
```

This directory had been full of mail files before. (Fortunately I saved them to another directory.)

Any ideas?

----------

## nbensa

hmmm.... Show me 

```
ls -l /etc/sasl2
```

----------

## cyclohexan

ls -l /etc/sasl2 says:

```
total 388

-rw-r----- 1 root mail 393273 May  9 01:01 sasldb2
```

----------

## nbensa

Is your cyrus user member of mail group?

----------

## nbensa

Sorry. On a second read, your cyrus is working, just no emails there. Can you restore your /var/spool/imap/j/jan directory?

BTW, mine is /var/spool/imap/n/user/nbensa ... Is yours a typo?

----------

## cyclohexan

Oh, my fault. In /var/spool/imap/j/user/jan/ my mails are still stored.

Is it not normal that the dir /var/spool/imap/j/jan/ exists? Perhaps I created it accidentally while playing with cyradm...

No, my user is not in the mail group. Is that necessary?

----------

## cyclohexan

OK, I solved my problem the following way:

1. I installed dovecot

2. I wrote a script to convert the cyrus maildir into a dovecot maildir

3. I said bye bye to cyrus

The second step was necessary, because neither cyrus2courier nor cyrus2maildir.py worked for me.

If anyone is interested in the script, just let me know.

Anyway, thanks for your help, nbensa.

----------

## luispa

 *nbensa wrote:*   

> Thanks Janne. I've tried that before but it didn't fix anything. Finally, I did:
> 
> ```
> rm /var/imap/*.db
> 
> ...

 

Same problem here, doing the above also solved the problem

Luis

----------

## aZZe

Hi!

I had exactly the same problem. I also deleted the dp files in /var/imap. But now I have also the problem that my mail client tells me the mailbox doesn't exist. When I use cyradm I still see my mailbox with its quota etc. So how do I tell the database that the mailbox still exists?

----------

