4

I have used Emacs Org mode for my notes for several years, and I use Prelude configured with evil. Everything works fine. Until a few minutes ago, I found the note file is empty of content. and the file size change to 2 bytes. I try to undo but it's useless(I get nothing through undo). How can it be fixed?

  • 3
    Sorry to hear this. Unfortunately, I'm sorry to say I expect you'll need to provide more info if possible, to see if someone here can offer some help. Try to remember and report anything about what you did that you think might be relevant. From now on, of course, you'll want to back up important files from time to time. Let this at least serve as a lesson, to help insure against another such loss. – Drew Sep 11 '18 at 4:34
  • 1
    undo-tree keeps the edits from session to session if it is configured to store the history file. If you have a history file, you it may be a good idea to open it up and see if it has anything helpful. If the history has been discarded, however, you may need to restore the master file from a backup somewhere else (assuming you keep regular backups of your important data). For example, if undo-tree is configured to store history as a file from session to session and you did a select whole buffer and cut/delete, then the history file may have everything. However, there are data limits ... – lawlist Sep 11 '18 at 4:53
  • Thanks @Drew . I found a backup three month ago. I checkd my shell history and emacs message and found nothing cause this situation bug get 1 message at emacs message: "Buffer inbox.org has shrunk a lot; auto save disabled in that buffer until next real save" . I'm use manjaro with ext4 fs.Is there any way to recover the file? – chiangxinyu Sep 11 '18 at 6:19
  • 1
    Welcome to the site. Please amend question: amendments in comments are less likely to be seen. (and what ever you do don't do a save, it appears that there is an auto-save.) – ctrl-alt-delor Sep 11 '18 at 7:36
  • 2
    Here's something that you may find relevant: unix.stackexchange.com/questions/116376/… However, keep in mind: the longer your system stays mounted in read-write mode, the worse are your chances of recovering the bits of truncated file. – wvxvw Sep 11 '18 at 12:36
3

In a shell window, make a backup of your files (now), including the autosave files.

After backup. You can probably copy the autosave file over the empty file.

However, and this is very important, make a backup, before you start trying to fix it.

Then when all is good (or not), you need to create a backup strategy, for all of your important data.

  • This is good advice, useful help for the OP. The part of it that is actually an answer to the question is the part that suggests that the lost info might already exist in autosave files. It might help if you make that part of the post clearer. If there are no autosave files then the rest of this post is helpful for the future but it won't help recover the lost data. – Drew Sep 11 '18 at 16:01
0

Thanks everyone and sorry to reply this sooooo late. By following @wvxvw's answer I have recovered the lost data after 2 days. And I have created cron job to auto commit and push data to git repository for backup. Thanks again for your anwser.

  • This might be better added as an update to the question (as that's what it is), rather than as a separate answer (which it isn't). – owjburnham Sep 19 '18 at 8:31
  • should I remove the answer and add an update? Sorry. I'm a newbie for this. It's my first post – chiangxinyu Sep 19 '18 at 8:42
  • I saw! I'm not super-experienced either, but it seems like norm for these things (on other SE sites at least -- I don't know about Emacs SE) is that if people post an update they add it to the question or, maybe, as a comment to the question. But because 'Answers' get rated up and down, and move accordingly, the Answers section doesn't work like a regular forum with everything in chronological order. I'd say that yes, you're probably best off editing the Question to add your update, and then removing the 'Answer'. – owjburnham Sep 19 '18 at 9:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.