Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > HELP! Restoring a users mail from backup (OS X Server 10.3)

HELP! Restoring a users mail from backup (OS X Server 10.3)
Thread Tools
pwharff
Fresh-Faced Recruit
Join Date: Aug 2003
Status: Offline
Reply With Quote
Mar 11, 2005, 12:47 PM
 
THE STORY:
I upgraded a user on our network from Outlook to Mozilla's Thunderbird for IMAP email. After this, the user went back into Outlook and deleted all the emails from there thinking he was going to save space and why should he have email on both Outlook and TBird. Well ofcourse by doing this, he deleted all his email. Fortunately we do a weekly backup of the system.

THE PROBLEM:
I feel pretty sure on how to restore this persons email from backup, but I want to make sure I get it right:

1) Stop the Mail Services in Server Admin
2) Copy /var/spool/imap/user/PersonsUsername from backup to replace the current one on the server.
3) Restart the Mail Services in Server Admin

Is above the correct procedure?

Any help is appreciated, I would like to make this restore with as few of problems as possible. Thanks in advance.
     
utidjian
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Mar 11, 2005, 04:43 PM
 
Originally posted by pwharff:
THE STORY:
I upgraded a user on our network from Outlook to Mozilla's Thunderbird for IMAP email. After this, the user went back into Outlook and deleted all the emails from there thinking he was going to save space and why should he have email on both Outlook and TBird. Well ofcourse by doing this, he deleted all his email. Fortunately we do a weekly backup of the system.

THE PROBLEM:
I feel pretty sure on how to restore this persons email from backup, but I want to make sure I get it right:

1) Stop the Mail Services in Server Admin
2) Copy /var/spool/imap/user/PersonsUsername from backup to replace the current one on the server.
3) Restart the Mail Services in Server Admin

Is above the correct procedure?

Any help is appreciated, I would like to make this restore with as few of problems as possible. Thanks in advance.
Heh... been there and done that. I would modify your three steps thus (sudo su -):

1) Copy /var/spool/imap/user/PersonsUsername from backup to /var/spool/imap/user/PersonsUsername.tmp
2) cd /var/spool/imap/user/
3) ls -l /var/spool/imap/user/PersonsUsername
(note the ownership and permissions on that file)
4) Stop the Mail Services in Server Admin
5) cp PersonsUsername PersonsUsername.recent
(Just in case something goes wrong )
6) cat PersonsUsername >> PersonsUsername.tmp
Which will append their latest mail to their old backed up mail. DO NOT forget the >>.
7) mv PersonsUsername.tmp PersonsUsername
Which will replace their current mail with the old + new mail.
8) Repeat step (3) and adjust ownership and permissions if necessary.
9) Restart the Mail Services in Server Admin

The reason to do the copy to a tmpfile in the correct folder before stopping the service is, depending on the size of their old mail spool this can take some time. They may be receiving emails while it is copying over from backup media.
Once you are in the correct folder you can stop the mail server. Most mail servers handle this gracefully in that if there is an incoming email it will write it to the spool before stopping OR it will reject it which will cause the sending server to retry again later.
cat-ting the most recent mail file to the copy of the backup will bring everything up to date as if they had never deleted any mail. This will take very little time. Then the mv (basically a rename) will take almost no time at all. This method will give you minimum downtime (a few seconds) and a maximum of data integrity (all data where it should be).
-DU-...etc...
     
pwharff  (op)
Fresh-Faced Recruit
Join Date: Aug 2003
Status: Offline
Reply With Quote
Mar 11, 2005, 07:11 PM
 
First off, thank you for your help. I've posted this very same thing at Apple discussions and MacOSXhints.com and so far no one has been willing to help (I think their scared. )

This sounds like it would work fine, however I do not know that you can "cat" a folder which is what PersonsUsername is, as you mentioned in step 6. Any suggestions?
     
utidjian
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Mar 12, 2005, 03:10 AM
 
Originally posted by pwharff:
First off, thank you for your help. I've posted this very same thing at Apple discussions and MacOSXhints.com and so far no one has been willing to help (I think their scared. )

This sounds like it would work fine, however I do not know that you can "cat" a folder which is what PersonsUsername is, as you mentioned in step 6. Any suggestions?
Yeah sorry... you are quite correct. On a Cyrus-IMAP server you can not simply cat the two files together. I did a LOT of reading up on the problem of backups and restores of Cyrus-IMAP servers. I was thinking the users mail spool files were in the standard Unix mbox format. If they were, you could simply cat them together. The structure of Cyrus-IMAP complicates things quite a bit. Not only is each email in a separate file (within the user folder) but there are several database files. One per user to keep track of which file is which mail and one overall file for the whole server. There may be several other databases besides for keeping track of other stuff. Seems to depend on each implementation.

In short... it seems you will be better off with your original plan of stopping the server copying over the folder from backup and restarting the server. However... you will lose the new emails (from the server) that the user has received since they deleted all the old ones. Which may not be a big deal but is still a PITA.

I can only see one way of re-syncing the backup folder with the current folder but it is somewhat risky. One could conceivably:

1) Stop the server
2) Copy over mail file contents of the backup PersonsUsername/ folder into some temporary folder
3) Then the contents of the current PersonsUsername/ folder into that temporary folder while renaming the individual files so that they don't overwrite files that may have the same name.
4) The replace the current folder with the temporary folder.
5) Then running the command:
Code:
su cyrus /usr/bin/cyrus/bin/reconstruct -r -f /var/spool/imap/PersonsUsername
6) Restart the server.

The above might work but I am somewhat skeptical of the robustness of the whole 'reconstruct' command. From what I have read the Cyrus-IMAP people don't put too much confidence in it.... though Apple seems to (I copied the command from the Apple manual). I am not sure why Apple chose such a fragile IMAP solution for Mac OS X Server but they must have their reasons. Supposedly Cyrus-IMAP is a very scaleable and efficient email server. This is good if you have a lot of users. It is not so good that it is difficult to backup and restore.

For more info on all of this here are some of the links I found:
http://images.apple.com/server/pdfs/Mail_Service.pdf
see page 35
http://acs-wiki.andrew.cmu.edu/twiki...tructMailboxes
http://asg.web.cmu.edu/cyrus/downloa.../overview.html
http://asg.web.cmu.edu/cyrus/downloa....html#recovery
Additional docs.

Best of luck whatever you decide to do. I will be very interested to hear how it works out.
-DU-...etc...
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:24 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,