Archive Page 3

Cyrus IMAP Backups

So I spent part of last week working on Cyrus IMAP backups. The intention was simple: If we’re rsyncing the files to a backup store it should be possible to prove that they work.

Not necessarily.

The idea was to take our mailspool backup from a Cyrus 2.1 install and import into 2.2. The Ubuntu upgrade guide told me to upgrade the databases. What databases? I inherited this thing without documentation. All I could see were email files in a tree like directory structure. Anyway, apparently I should follow the 1.5 to 2.x upgrade instructions. I ran a series of commands from the guide knowing I could re-restore if things went badly. Which they did, having no idea what I was doing I decided to re-restore.

However, a more detailed look into what was wrong was needed. And I discovered that some files were missing. Yes apparently another directory file of configuration and status information was on the production server. It made sense, there had to be permissions saved somewhere.

So I added this config /var/lib/cyrus/ directory to the rsync script and restored again. This time ensuring that after re-installing that Cyrus 2.1 (given up trying 2.2) packages I restored without rsync’s -u flag which doesn’t overwrite newer files. Kind important for restoring old consistent files.

Restoring the /var/spool/cyrus and /var/lib/cyrus directories took almost four hours. Then came the /etc/cyrus.conf and /etc/imapd.conf and not forgetting the /etc/sasldb2 file. Oh and because this machine had a different hostname to the production server I needed to add root@newserver and myaccount@newserver to the SASL database: saslpasswd2 root@newserver not difficult to do.

Finally it was up and running, and I connected from another LAN desktop. I could re-subscribe to my folders and see mail I had already read. Fantastic.

Only one problem to “prove” how to do now: backup and (more importantly) partial mailbox restoration. Oh no! Our sales mailbox got wiped. Do you have a backup? Yes from 5am. Well that will have to do. But I don’t know how to restore that mailbox without restoring the others too.

Guess: Restore the email directory structures and run within cyradm ‘reconstruct mailboxname’. Fingers crossed for when I try this later.

Summary of what to do (full backup and full restoration):

rsync -zarle ssh /var/spool/cyrus/* backup.host.com:/backup/spool/cyrus/
rsync -zarle ssh /var/lib/cyrus/* backup.host.com:/backup/lib/cyrus/
rsync -zarle ssh /etc/* backup.host.com:/backup/etc/

To restore: The opposite of the above. Literally. You might want to selectively restore imapd.conf and cyrus.conf for obvious reasons.


Categories