4

I am trying to backup my email server with dovecot. I have read the doveadm command documentation but it is unclear on how to use it.

I have create a test directory /dove_backup and then trying to backup with:

doveadm backup -A maildir:/dove_backup but the command throws error as it does not have permissions to write to the directory.

After granting 777 permissions it does write but there are no directories of the users but only files.

1
  • Did you try that command with sudo?
    – Alex Jones
    May 5, 2021 at 19:19

3 Answers 3

3

if you use mdbox, you should use doveadm backup and not rsync. With rsync there is a risk that the index will break, it can't simply be rebuilt.

For mbox / mdbox / mailDir you can use this command:

doveadm backup -u user1 mdbox:/home/backup/user1/

The command explained:

doveadm backup -u user1
dsync backup -u user1

That two varaints do the same: you call the doveadm and tell it, you would like to a backup for all mails from user1. Doveadm take the information about the mail location from the variable "mail_location" from the dovecot config.

mdbox:/home/backup/user1/

This part regulates the target backup mail-format, in my case: mdbox => if you want, your backups schould stored as mailDir you use:

maildir:/home/backup/user1

More informations: https://wiki2.dovecot.org/Tools/Doveadm/Sync

BTW: If you use mdbox, you are able to use live compression: https://doc.dovecot.org/configuration_manual/zlib_plugin/

5
  • Could you please provide more details on how to do this?
    – helt
    Jul 26, 2020 at 9:04
  • What about maildir?
    – Alex Jones
    May 5, 2021 at 19:18
  • oh f**k i didn´t see your comments, sry.. @helt => dsync backup -u "<[email protected]>" mdbox:~/mdbox-Backup
    – NETFLOX
    May 6, 2021 at 8:22
  • @EdwardTorvalds you also can use dsync (or doveadm sync backup), you also are able to use rsync, with maildir its acually the same => i would prefere dsync.
    – NETFLOX
    May 6, 2021 at 8:23
  • @Rudi great thanks :) Better late than never :)
    – helt
    May 15, 2021 at 8:20
2

Simply tar czf mailstorage.tgz /path/to/maillocation. doveadm backup is intended to syncronize the mail storages between two instances of the dovecot, not for creating the archives.

6
  • 1
    Oh ok. So a simple backup is enough. The issue is that files will sometimes change as the server is running and the backup says it has failed. Dec 16, 2018 at 18:07
  • 2
    You can rsync -aR --del -q /pathto/mailstorage /temp/mailstorage few times (only first run will be lasting for a while) and then tar the copy.
    – Kondybas
    Dec 16, 2018 at 19:26
  • Thanks. So in order to keep an updated copy I can create a cron that will run the command daily and it will do a diff update? Dec 16, 2018 at 19:48
  • 1
    Sure. Also rsync is able to copy the tree over the network so you can syncronize between different hosts.
    – Kondybas
    Dec 16, 2018 at 19:57
  • 1
    I thought that copying the live mail storage location was a no no? And I thought doveadm-backup was for both syncing servers AND backing up all mail?
    – l008com
    Jan 22, 2019 at 19:29
1

dsync? Stumbled across it, didn't try. tachtler/dovecot-backup uses it and its manpage says:

dsync is Dovecot's mailbox synchronization utility. It can be used for several different use cases: Two-way synchronization of mailboxes in different servers (via ssh(1)), creating backups of mails to a remote server, and convert mailboxes from/to different mailbox formats.

1
  • This should be the selected answer. Although after backing up mail files into another location one should zip/tar the folder and copy it into another machine.
    – Alex Jones
    May 6, 2021 at 7:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .