Currently Being ModeratedMay 7, 2013 9:23 PM (in response to Dean Huxley)
This link may help you, http://databasically.com/2009/01/16/restore-imap-mail-from-local-cache-via-time- machine/
Currently Being ModeratedMay 8, 2013 11:42 AM (in response to Eric Ross)
Thanks for the link Eric, but unfortunately it didn't meet my needs. I've since learned that the local cache may not always be up to date and it doesn't look like Notes are cached under ~/Library/Mail/ anymore (mine were all old ones from 2012).
Currently Being ModeratedMay 8, 2013 12:48 PM (in response to Linc Davis)
Last night I restored the directory from Time Machine and it worked like a charm. The users Notes application that had been crashing consistently when starting now works fine.
Here's what I did:
- in Terminal window as root, I perused the directories under /Library/Server/Mail/Data/mail until I found the one belonging to the user with the corrupted imap directory. It's a series of hex digits mixed with some hyphens.
- While in Terminal, I used "open ." to open a Finder window in /Library/Server/Mail/Data/mail (I could have used the Finder's Go to Folder, but I'm lazy)
- From the Time Machine menulet, selected "Enter Time Machine"
- I already knew the corruption happened a little after 8AM so I went back to the previous backup which happened to be 7:51AM.
- Just before doing the restore, I ran "sudo serveradmin stop mail" in the Terminal window
- To do the restore, I right clicked (or control clicked on a one button mouse) the long hex digit directory I determined in step one, then selected the "Restore ### to ..." option.
- after a few seconds of reading backup files I was prompted for the directory to restore to and I picked the directories to get /Library/Server/Mail/Data/mail.
- I was told the directory already existed and I chose to replace it.
- Time Machine finished the restore, then I ran "sudo serveradmin start mail" in the Terminal Window
- On a client machine I tried opening Mail and Notes and looking around and everything was exactly as it was at 7:51AM!
What I would do differently next time:
In retrospect, restoring the whole users imap directory was overkill. After reading some of the dovecot mailing list archives, it appears that dovecot is amazingly resilient. What I should have tried was to just restore the users .Notes directory (under /Library/Server/Mail/Data/mail/<long hex string>) This was likely the only source of corruption in this particular case and if it didn't work I could have then fallen back to restoring the whole user imap directory.
Apparently, for anyone wanting to do a restore of just one folder in a users imap directory the instructions would be something like this:
- in a Terminal window run "sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder" This will open a Finder window with full root access! BE CAREFULL!
- Go to Folder /Library/Server/Mail/Data/mail/
- Figure out which hex digit subdirectory belongs to the user. (I wish I had a better idea on how to determine the mapping. I found the one I wanted quickly based on the subfolder names underneath matching the users mail folders but I was using a Terminal window and ls commands which show the directories starting with periods - Finder doesn't)
- Go to Folder /Library/Server/Mail/Data/mail/<big hex string>/.<mail folder to restore>
- Enter Time Machine via the menulet
- Find the version that you want to restore then right or control click the folder and pick the "Restore to..." option
- Create a new folder with _restore appended to the name (eg. /Library/Server/Mail/Data/mail/<big hex string>/.<mail folder to restore>_restore )
- Finish the restore and close the root Finder window.
Presumably creating a new folder with the restored files wouldn't require the mail service to be stopped/started and dovecot would apparently show the new mail folder in the users mail client where they could then drag & drop the emails they wanted to keep then delete the "..._restore" folder when they were done.
Sorry for the long winded response. Hopefully someone else finds this useful in the future.
Currently Being ModeratedJan 14, 2014 5:41 PM (in response to Dean Huxley)
Dean Huxley wrote:
... Figure out which hex digit subdirectory belongs to the user. (I wish I had a better idea on how to determine the mapping. I found the one I wanted quickly based on the subfolder names underneath matching the users mail folders but I was using a Terminal window and ls commands which show the directories starting with periods - Finder doesn't)
Give these a try:
dscl . read /Users/username | grep UID
dscl . search /Users GeneratedUID <big hex string>
Currently Being ModeratedJan 14, 2014 10:05 PM (in response to tpesce)
All good info.... just want to add (for benefit of others searching).
This command will return the GUID for local and network users
(replace username with the real username)
dscl /Search -read /Users/username/ GeneratedUID
Using /Search as your base makes locating a user easier, it doesn't matter whether they are local or a dir user.