[Dovecot] Backup recovery with mdbox
Hello
I'm using mdbox for mail storage. I'd like to give users an option to recover backups into a new folder, say, Backup-$date.
Is there a simple way to do this? I was looking at tools like dsync and doveadm-altmove but apparently they're not intended for this kind of stuff.
Thanks in advance, Andre
On 5.10.2010, at 13.56, Andre Nathan wrote:
I'm using mdbox for mail storage. I'd like to give users an option to recover backups into a new folder, say, Backup-$date.
Is there a simple way to do this? I was looking at tools like dsync and doveadm-altmove but apparently they're not intended for this kind of stuff.
dsync could work, although with some small kludging:
Put the old backup to e.g. ~/backup
Rename the mailbox to whatever you want in destination, e.g. mv ~/backup/mailboxes/foo ~/backup/mailboxes/foo-$date
Copy the mailbox: dsync -m foo-$date mirror mdbox:~/backup
On Tue, 2010-10-05 at 14:13 +0100, Timo Sirainen wrote:
dsync could work, although with some small kludging:
Put the old backup to e.g. ~/backup
Rename the mailbox to whatever you want in destination, e.g. mv ~/backup/mailboxes/foo ~/backup/mailboxes/foo-$date
Copy the mailbox: dsync -m foo-$date mirror mdbox:~/backup
Hello
I'm doing the following:
Backups are extracted in /home/andre/backup/{spool,lib}
The user mail_location is mdbox:/var/spool/imap/partition7/11/andre=sneakymustard.com:INDEX=/var/lib/imap/user/11/andre=sneakymustard.com
I tried the following commands:
dsync -R -u andre=sneakymustard.com -m backup_2010-10-01-23 backup
"mdbox:/home/andre/backup/spool:INDEX=/home/andre/backup/lib"
# dsync -u andre=sneakymustard.com -m backup_2010-10-01-23 -o mail_location="mdbox:/home/andre/backup/spool:INDEX=/home/andre/backup/lib" backup "mdbox:/var/spool/imap/partition7/11/andre=sneakymustard.com:INDEX=/var/lib/imap/user/11/andre=sneakymustard.com
The intent is that a folder called "backup_2010-10-01-21" is created in that mailbox, with the contents from /home/andre/backup stored in it, but nothing is created. I believe this is because there's no "backup_2010-10-01-21" folder in the recovered backup. Is there a way around this?
Thanks, Andre
On Wed, 2010-10-06 at 11:14 -0300, Andre Nathan wrote:
# dsync -u andre=sneakymustard.com -m backup_2010-10-01-23 -o mail_location="mdbox:/home/andre/backup/spool:INDEX=/home/andre/backup/lib" backup "mdbox:/var/spool/imap/partition7/11/andre=sneakymustard.com:INDEX=/var/lib/imap/user/11/andre=sneakymustard.com
The intent is that a folder called "backup_2010-10-01-21" is created in that mailbox, with the contents from /home/andre/backup stored in it,
You mean all mailboxes under that?
but nothing is created. I believe this is because there's no "backup_2010-10-01-21" folder in the recovered backup. Is there a way around this?
Yeah, there's currently no way to restore entire hierarchy of mails, you'd have to do it one mailbox at a time. Or .. hmm. there are some pretty horrible workarounds though.. For example you could do:
dsync -o mail_location=mdbox:mdbox:/var/spool/imap/partition7/11/andre=sneakymustard.com:INDEX=/var/lib/imap/user/11/andre=sneakymustard.com:MAILBOXDIR=mailboxes/backup-1234 -u ..etc..
So basically override the default mail_location but only change the mailboxes/ directory to mailboxes/backup-1234. I think that should work. Take a backup first. :)
On Wed, 2010-10-06 at 15:26 +0100, Timo Sirainen wrote:
dsync -o mail_location=mdbox:mdbox:/var/spool/imap/partition7/11/andre=sneakymustard.com:INDEX=/var/lib/imap/user/11/andre=sneakymustard.com:MAILBOXDIR=mailboxes/backup-1234 -u ..etc..
So basically override the default mail_location but only change the mailboxes/ directory to mailboxes/backup-1234. I think that should work. Take a backup first. :)
That worked, as long as I run a
doveadm force-resync -u andre=sneakymustard.com INBOX
after dsync, which is totally fine :)
Thanks! Andre
On Wed, 2010-10-06 at 12:08 -0300, Andre Nathan wrote:
That worked, as long as I run a
doveadm force-resync -u andre=sneakymustard.com INBOX
after dsync, which is totally fine :)
Hmm actually it doesn't work after a force-resync. The "backup-$date" mailbox is shown, with all it's sub-mailboxes as intended, but they're all empty.
I found out, though, that if I run the dsync command twice the messages appear on the imap client. I get log messages like these on the second run:
dsync(andre=sneakymustard.com): Info: SPAM: uidnext changed: 31 != 1 dsync(andre=sneakymustard.com): Info: INBOX: uidnext changed: 314 != 1
Is this what makes it work (it fixes the uids or something like that)? Does the second dsync do something that could cause the message listing to be fixed (apparently something that a force-resync doesn't do...)?
I have no problem running the command twice, it's just a bit weird...
Thanks, Andre
On Tue, 2010-10-05 at 09:56 -0300, Andre Nathan wrote:
I'm using mdbox for mail storage. I'd like to give users an option to recover backups into a new folder, say, Backup-$date.
Added to hg:
This example imports all mails from a backup under a backup-20101026
mailbox:
doveadm import -u jane.doe@example.org \
mdbox:/backup/20101026/jane.doe/mdbox backup-20101026 all
Another example that imports only messages from foo@example.org in the
backup mdbox's INBOX to jane's INBOX:
doveadm import -u jane.doe@example.org \
mdbox:~/mdbox-backup mailbox INBOX from foo@example.org
On Mon, 2010-10-18 at 18:38 +0100, Timo Sirainen wrote:
Added to hg:
This example imports all mails from a backup under a backup-20101026 mailbox: doveadm import -u jane.doe@example.org \ mdbox:/backup/20101026/jane.doe/mdbox backup-20101026 all Another example that imports only messages from foo@example.org in the backup mdbox's INBOX to jane's INBOX: doveadm import -u jane.doe@example.org \ mdbox:~/mdbox-backup mailbox INBOX from foo@example.org
Awesome :) Thanks a lot!
Andre
participants (2)
-
Andre Nathan
-
Timo Sirainen