folder restore for Zimbra users
December 21st, 2007
I ran into a situation where a service recipient had deleted their Zimbra sent folder. Zimbra NE allows me to restore the user’s account to another account just fine but then what do I do to get the mail folder over to the production account. I ended up spending the weekend coding an automated restore. Right now it is very “alpha” but I thought I had better share my code with people out there who are hurting like I was. [download: http://www.troyadams.ca/code/zmcopyfolder]
For mini mock disaster (simulation) we will:
- backup
- mutilate a folder
- restore
This is documentation is an account of the disaster simulation that I demonstrated to one of my service recipients. I ran a full backup on his account, and then asked him to delete the /z folder, and then runto me screaming about it.
The backup:
[10:30 root@avocado ~] # su zimbra -c 'zmbackup --fullBackup --account user@mydomain.com' full-20071221.173957.494 [10:39 root@avocado ~] # su zimbra -c 'zmbackupquery' | head -8 Label: full-20071221.173957.494 Type: full Status: completed Started: Fri Dec 21 10:39:57 MST 2007 Ended: Fri Dec 21 10:39:59 MST 2007 Redo log sequence range: 526 .. 526 Number of accounts: 1 [10:40 root@avocado ~] #
Oh look, a user just walked in and said “help, I’ve deleted the Zed folder!” Let’s take a look:
[10:47 root@avocado ~] # zmmailbox -z -m user search -l 20 -t mess 'in:z' ERROR: mail.NO_SUCH_FOLDER (no such folder path: /z) [11:10 root@avocado ~] #
Okay, it’s gone. Now we restore the account to restored_user@mydomain.com:
[11:10 root@avocado ~] # su zimbra -c 'zmrestore --createAccount --prefix restored_ --restoreFullBackupOnly --account user@mydomain.com' [11:11 root@avocado ~] # [11:12 root@avocado ~] # zmmailbox -z -m restored_user search -l 3 -t mess 'in:z' num: 3, more: true Id Type From Subject Date ----- ---- -------------------- -------------------------------------------------- -------------- 1. 18912 mess Trent Re: discard_emails_for_the_day 12/16/07 01:40 2. 18907 mess Jan Re: Free to good home corner computer 12/14/07 18:10 3. 18914 mess Kathy admin auth passwords 12/14/07 15:15 [11:12 root@avocado ~] #
Next, we run zmcopyfolder to get the mail folder to the production account:
[11:13 root@avocado ~] # time bin/zmcopyfolder --source restored_user@avocado.cs.mydomain.com:/z > --destination user@avocado.cs.mydomain.com:/z --noverify --verbose --forks 16 source: restored_user@avocado.cs.mydomain.com:/z destination: user@avocado.cs.mydomain.com:/z zmcopyfolder: source target contains 49 messages zmcopyfolder: copying... QUEUED 1 of 49 QUEUED 2 of 49 QUEUED 3 of 49 QUEUED 4 of 49 QUEUED 5 of 49 QUEUED 6 of 49 QUEUED 7 of 49 QUEUED 8 of 49 QUEUED 9 of 49 QUEUED 10 of 49 QUEUED 11 of 49 QUEUED 12 of 49 QUEUED 13 of 49 QUEUED 14 of 49 QUEUED 15 of 49 QUEUED 16 of 49 DEQUEUED 1 of 49 QUEUED 17 of 49 DEQUEUED 2 of 49 QUEUED 18 of 49 DEQUEUED 3 of 49 QUEUED 19 of 49 DEQUEUED 4 of 49 QUEUED 20 of 49 DEQUEUED 5 of 49 QUEUED 21 of 49 DEQUEUED 6 of 49 QUEUED 22 of 49 DEQUEUED 7 of 49 QUEUED 23 of 49 DEQUEUED 8 of 49 QUEUED 24 of 49 DEQUEUED 9 of 49 QUEUED 25 of 49 DEQUEUED 10 of 49 QUEUED 26 of 49 DEQUEUED 11 of 49 QUEUED 27 of 49 DEQUEUED 12 of 49 QUEUED 28 of 49 DEQUEUED 13 of 49 QUEUED 29 of 49 DEQUEUED 14 of 49 QUEUED 30 of 49 DEQUEUED 15 of 49 QUEUED 31 of 49 DEQUEUED 16 of 49 QUEUED 32 of 49 DEQUEUED 17 of 49 QUEUED 33 of 49 DEQUEUED 18 of 49 QUEUED 34 of 49 DEQUEUED 19 of 49 QUEUED 35 of 49 DEQUEUED 20 of 49 QUEUED 36 of 49 DEQUEUED 21 of 49 QUEUED 37 of 49 DEQUEUED 22 of 49 QUEUED 38 of 49 DEQUEUED 23 of 49 QUEUED 39 of 49 DEQUEUED 24 of 49 QUEUED 40 of 49 DEQUEUED 25 of 49 QUEUED 41 of 49 DEQUEUED 26 of 49 QUEUED 42 of 49 DEQUEUED 27 of 49 QUEUED 43 of 49 DEQUEUED 28 of 49 QUEUED 44 of 49 DEQUEUED 29 of 49 QUEUED 45 of 49 DEQUEUED 30 of 49 QUEUED 46 of 49 DEQUEUED 31 of 49 QUEUED 47 of 49 DEQUEUED 32 of 49 QUEUED 48 of 49 DEQUEUED 33 of 49 QUEUED 49 of 49 zmcopyfolder: done copying. zmcopyfolder: destination target contains 49 messages: real 3m36.798s user 11m51.627s sys 0m31.335s [11:17 root@avocado ~] # [11:17 root@avocado ~] # zmmailbox -z -m user search -l 3 -t mess 'in:z' num: 3, more: true Id Type From Subject Date ----- ---- -------------------- -------------------------------------------------- -------------- 1. 18976 mess Trent Re: discard_emails_for_the_day 12/16/07 01:40 2. 18984 mess Jan Re: Free to good home corner computer 12/14/07 18:10 3. 18979 mess Kathy admin auth passwords 12/14/07 15:15 [11:18 root@avocado ~] #
It looks like that worked just fine.
Later on, the user said everything looked good!
I hope this helps!
cheers,
Troy



