VM User's Manual. Node: Crash Recovery

PREV Getting New Mail UP Starting Up next

1.5: Crash Recovery

When Emacs crashes, its last action before dying is to try to write out an autosave file that contains changes to files that you were editing. VM folders are file buffers inside Emacs, so folders are autosaved also. Changes, with regard to VM folders, means attribute changes, label additions and deletions, message edits, and expunges. VM keeps track of whether a message is new or old, whether it has been replied to, whether it is flagged for deletion and so on, by writing special headers into the folder buffer. These headers are saved to disk when you save the folder. If Emacs crashes before the folder has been saved, VM may forget some attribute changes unless they were written to the autosave file.

Note that when VM retrieves mail from spool files it always writes them to disk immediately and at least one copy of the message is on disk at all times. So while you can lose attribute changes from crashes, you should not lose messages unless the disk itself is compromised.

When you visit a folder, VM checks for the existence of an autosave file that has been modified more recently than the folder file. If such an autosave file exists, there is a good chance that Emacs or your operating system crashed while VM was visiting a folder. VM will then write a message to echo area informing you of the existence of the autosave file and visit the folder in read-only mode. Visiting the folder in read-only mode prevents you from modifying the folder, which in turn prevents Emacs from wanting to write new changes to the autosave file. VM will not retrieve new mail for a folder that is in read-only mode.

If you want to recover the lost changes, run M-x recover-file or use the Recover toolbar button, if you're using XEmacs. At the `Recover File: ' prompt press RET. Emacs will then display a detailed directory listing showing the folder file and the autosave file and ask if you want to recover from the autosave file. A good rule of thumb is to answer ``yes'' if the autosave file is larger than the folder file. If the autosave file is significantly smaller Emacs may not have completed writing the autosave file. Or it could be that the smaller autosave file reflects the results of an expunge that you had not yet committed to disk before the crash. If so, answering ``no'' means you might have to do that expunge again, but this is better than not knowing whether the autosave file was truncated.

Assuming you answered ``yes'', the folder buffer's contents will be replaced by the contents of the autosave file and VM will reparse the folder. At this point the contents of the folder buffer and the disk copy of the folder are different. Therefore VM will not get new mail for this folder until the two copies of the folder are synchronized. When you are satisfied that the recovered folder is whole and intact, type S to save it to disk. After you do this, VM will allow you to use g to retrieve any new mail that has arrived in the spool files for the folder.

Assuming you answered ``no'' to the recovery question, you should type C-x C-q, which is bound to vm-toggle-read-only in VM folder buffers. The folder will be taken out of read-only mode and you can read and retrieve your mail normally.

PREV Getting New Mail UP Starting Up next