# Delayed Expunge¶

When a user or IMAP client expunges a message or an entire folder, messages become unavailable to the user.

When the deletion is accidental, administrators may have to recover the messages from some place. When the messages are purposefully deleted, the user may have done so not with the best of intentions.

In any case, the time between a message arriving and being deleted may not be sufficient to ensure the message is replicated, included in the next backup cycle, and generally available for recovery or compliance with the regulatory environment.

Cyrus IMAP introduces delayed expunge, which ensures message files are not immediately unlinked from the filesystem, and instead makes purging the message files from the filesystem a separate event.

This enables administrators to quickly recover access to messages that have been accidentally deleted, as well as allows the environment to ensure messages remain available for includion in the next backup cycle.

## Configuring Cyrus IMAP for Delayed Expunge¶

To enable or disable Delayed Expunge, please check the following settings in imapd.conf(5).

expunge_mode: delayed

The mode in which messages (and their corresponding cache entries) are expunged. “default” mode is the old behavior in which the message files are purged at the time of the EXPUNGE, but index and cache records are retained to facilitate QRESYNC. (Note that this behaviour is no longer the default, but is so named for historical reasons.) In “delayed” mode, which is the default since Cyrus 2.5.0, the message files are also retained, allowing unexpunge to rescue them. In “immediate” mode, both the message files and the index records are removed as soon as possible. In all cases, nothing will be finally purged until all other processes have closed the mailbox to ensure they never see data disappear under them. In “default” or “delayed” mode, a later run of “cyr_expire” will clean out the retained records (and possibly message files). This reduces the amount of I/O that takes place at the time of EXPUNGE and should result in greater responsiveness for the client, especially when expunging a large number of messages. Allowed values: default, immediate, delayed

Back to Features