I maintain an IMAP server running Dovecot which uses Maildir as the storage format for the user mailboxes. Every night, an rsync process runs to create a backup of the mailboxes. Recently, I noticed that rsync occasionally prints messages like

file has vanished: "/home/vmail/lists/archive/Maildir/.sales/dovecot-uidlist.lock" rsync warning: some files vanished before they could be transferred (code 24) at main.c(1655) [generator=3.1.1]

My understanding based on the Locking section in the Dovecot wiki is that this lock file is a custom extension of Dovecot which is held while the dovecot-uidlist file is being written to. Hence, if a file is being delivered while the backup is running, it may happen that the .lock file gets removed during the backup - triggering above warning message.

It would be easy to exclude this lock file from the backup, but I wonder: should we maybe rather lock the mailbox (such that no modifications to it take place) during the rsync backup? If so, how can one do this using Dovecot?

  • By accident, I found that the Dovecot Zlib wiki page mentions a utility called maildirlock. Indeed, an older mail on the dovcot list mentions the same utility. I suspect that might be useful... Apr 18, 2018 at 8:23
  • Consider elaborating this a little as a self answer. :) Apr 18, 2018 at 14:00
  • 1
    Possible duplicate of Make consistent copy of maildir
    – derobert
    Apr 23, 2018 at 21:04
  • The way I do it for one-offs is to use doveadm to make a maildir+ format copy of the mailbox, then back up that. But this is probably not a good way if you need to do bulk backups regularly. Apr 25, 2019 at 1:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.