> On October 20, 2016 at 4:45 PM Konstantin Khomoutov <flatworm at users.sourceforge.net> wrote: > > > On Thu, 20 Oct 2016 09:18:12 -0400 > Jerry <jerry at seibercom.net> wrote: > > > I am running Dovecot with Postfix on a FreeBSD machine. There are > > problems with the drive and I cannot depend on it. Dovecot saves all > > mail in IMAP format. I want to back up the mail folders, install a new > > HD, install the latest FreeBSD OS and then reinstall my programs. > > Reinstalling Dovecot is simple, but how do I reinstall the IMAP > > folders? Can Dovecot backup the folders onto a CD and then import them > > when I reinstall it? My mail is kept under ?/var/mail/vmail?. Should I > > just back up that entire directory structure and then restore it > > later? > > That should work (just make sure Dovecot is not running to not have a > race between your backup software and the IMAP server and clients). > > Alternatively you can use `dsync` to perform backup with a native > Dovecot tool. It's able to sync mailboxes of any Dovecot user -- > including synchronizing a mailbox to an empty (yet) spool. > You'll need to do a bit of shell scripting which would spin around > calling `doveadm user *` and feeding its output to something like > > while read user; do \ > dest="/var/backup/dovecot/$user"; > mkdir -p "$dest" && chown vmail:vmail "$dest" \ > && chmod 0755 "$dest" > dsync -u "$user" backup "maildir:$dest" \ > done > > Note that you will only need this if you don't want to shut down > Dovecot to copy its mail spool out.You can also use doveadm backup -A maildir:%u/ Aki
On Thu, 20 Oct 2016 16:57:45 +0300 (EEST) Aki Tuomi <aki.tuomi at dovecot.fi> wrote: [...]> > Alternatively you can use `dsync` to perform backup with a native > > Dovecot tool. It's able to sync mailboxes of any Dovecot user -- > > including synchronizing a mailbox to an empty (yet) spool. > > You'll need to do a bit of shell scripting which would spin around > > calling `doveadm user *` and feeding its output to something like > > > > while read user; do \ > > dest="/var/backup/dovecot/$user"; > > mkdir -p "$dest" && chown vmail:vmail "$dest" \ > > && chmod 0755 "$dest" > > dsync -u "$user" backup "maildir:$dest" \ > > done > > > > Note that you will only need this if you don't want to shut down > > Dovecot to copy its mail spool out. > > You can also use doveadm backup -A maildir:%u/Looks like `doveadm` of my Dovecot 2.2 (Debian 8.0 Jessie) does not support the "backup" subcommand. Is it a past-2.2 addition?
> On October 20, 2016 at 5:11 PM Konstantin Khomoutov <flatworm at users.sourceforge.net> wrote: > > > On Thu, 20 Oct 2016 16:57:45 +0300 (EEST) > Aki Tuomi <aki.tuomi at dovecot.fi> wrote: > > [...] > > > Alternatively you can use `dsync` to perform backup with a native > > > Dovecot tool. It's able to sync mailboxes of any Dovecot user -- > > > including synchronizing a mailbox to an empty (yet) spool. > > > You'll need to do a bit of shell scripting which would spin around > > > calling `doveadm user *` and feeding its output to something like > > > > > > while read user; do \ > > > dest="/var/backup/dovecot/$user"; > > > mkdir -p "$dest" && chown vmail:vmail "$dest" \ > > > && chmod 0755 "$dest" > > > dsync -u "$user" backup "maildir:$dest" \ > > > done > > > > > > Note that you will only need this if you don't want to shut down > > > Dovecot to copy its mail spool out. > > > > You can also use doveadm backup -A maildir:%u/ > > Looks like `doveadm` of my Dovecot 2.2 (Debian 8.0 Jessie) does not > support the "backup" subcommand. Is it a past-2.2 addition?We aren't past 2.2 yet. But it should work with dsync -A backup as well I guess. Aki
On Thu, 20 Oct 2016 16:57:45 +0300 (EEST) Aki Tuomi <aki.tuomi at dovecot.fi> wrote: [...]> > Alternatively you can use `dsync` to perform backup with a native > > Dovecot tool. It's able to sync mailboxes of any Dovecot user -- > > including synchronizing a mailbox to an empty (yet) spool. > > You'll need to do a bit of shell scripting which would spin around > > calling `doveadm user *` and feeding its output to something like > > > > while read user; do \ > > dest="/var/backup/dovecot/$user"; > > mkdir -p "$dest" && chown vmail:vmail "$dest" \ > > && chmod 0755 "$dest" > > dsync -u "$user" backup "maildir:$dest" \ > > done > > > > Note that you will only need this if you don't want to shut down > > Dovecot to copy its mail spool out. > > You can also use doveadm backup -A maildir:%u/Could you please elaborate? I have a typical "virtual users" setup where I do have mail_home = /var/local/mail/%Ln mail_location = maildir:~/mail and everything is stored with uid=vmail / gid=vmail (much like described in the wiki, that is). I'd like to use a single call to `doveadm backup -A ...` to back up the whole /var/local/mail/* to another location (say, /var/backups/dovecot/) so that is has the same structure, just synchronized with the spool. (The purpose is to then backup the replica off-site). I tried to call doveadm backup -A maildir:/var/backups/dovecot/%u and it created a directory "/var/backups/dovecot/%u" (with literal "%u", that is), created what appeared to be a single mailbox structure under it and after a while scared a heck out of me with a series of error messages reading dsync(user1): Error: Mailbox INBOX sync: mailbox_delete failed: INBOX can't be deleted. dsync(user2): Error: Mailbox INBOX sync: mailbox_delete failed: INBOX can't be deleted. ... for each existing user. It appears that it luckily failed to delete anything in the source directory (though I have no idea what it actually tried to do). Reading the doveadm-backup(1) multiple times still failed to shed a light for me on how to actually backup the whole maildir hierarchy for all existing users. So, the question: how do I really should go about backing up the whole mailbox hierarchy in the case of virtual users?
On Thu, 20 Oct 2016 20:36:35 +0300, Konstantin Khomoutov stated:>On Thu, 20 Oct 2016 16:57:45 +0300 (EEST) >Aki Tuomi <aki.tuomi at dovecot.fi> wrote: > >[...] >> > Alternatively you can use `dsync` to perform backup with a native >> > Dovecot tool. It's able to sync mailboxes of any Dovecot user -- >> > including synchronizing a mailbox to an empty (yet) spool. >> > You'll need to do a bit of shell scripting which would spin around >> > calling `doveadm user *` and feeding its output to something like >> > >> > while read user; do \ >> > dest="/var/backup/dovecot/$user"; >> > mkdir -p "$dest" && chown vmail:vmail "$dest" \ >> > && chmod 0755 "$dest" >> > dsync -u "$user" backup "maildir:$dest" \ >> > done >> > >> > Note that you will only need this if you don't want to shut down >> > Dovecot to copy its mail spool out. >> >> You can also use doveadm backup -A maildir:%u/ > >Could you please elaborate? > >I have a typical "virtual users" setup where I do have > > mail_home = /var/local/mail/%Ln > mail_location = maildir:~/mail > >and everything is stored with uid=vmail / gid=vmail (much like >described in the wiki, that is). > >I'd like to use a single call to `doveadm backup -A ...` to back up the >whole /var/local/mail/* to another location >(say, /var/backups/dovecot/) so that is has the same structure, just >synchronized with the spool. (The purpose is to then backup the >replica off-site). > >I tried to call > > doveadm backup -A maildir:/var/backups/dovecot/%u > >and it created a directory "/var/backups/dovecot/%u" (with literal >"%u", that is), created what appeared to be a single mailbox structure >under it and after a while scared a heck out of me with a series of >error messages reading > >dsync(user1): Error: Mailbox INBOX sync: mailbox_delete failed: INBOX >can't be deleted. >dsync(user2): Error: Mailbox INBOX sync: mailbox_delete failed: INBOX >can't be deleted. >... > >for each existing user. > >It appears that it luckily failed to delete anything in the source >directory (though I have no idea what it actually tried to do). > >Reading the doveadm-backup(1) multiple times still failed to shed a >light for me on how to actually backup the whole maildir hierarchy for >all existing users. > >So, the question: how do I really should go about backing up the whole >mailbox hierarchy in the case of virtual users?I am experiencing the same problem as Konstantin. Is this s bug or expected behavior. -- Jerry