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).