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?
Asked
Active
Viewed 407 times
5
-
3Sorry 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 04: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 04: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 06:19
-
1Welcome 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 07:36
-
1Check `C-h v make-backup-files`. If the shown value is `t` backups are created when you save edited files. Backup files are created in several locations. Check [Backup info page](https://www.gnu.org/software/emacs/manual/html_node/emacs/Backup.html). Try `backup-directory-alist`. If the its value is `nil` backups are created in the directory of the original file. Check for a file that starts with the same name as the original file and has a `~` attached. It may also have a version string `.~1~` (or other numbers) attached. That depends on the value of the variable `version-control`. – Tobias Sep 11 '18 at 08:01
-
2Here's something that you may find relevant: https://unix.stackexchange.com/questions/116376/recovering-truncated-file 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
-
Besides all other suggestions that you should look at your backup files (and have a backup strategy in future) If you're on linux, the disc space is usualle not immediately overwriten so there's a good change you can revcover the data with dd or like. Have a look at https://unix.stackexchange.com/a/80285/180764 – dakra Sep 11 '18 at 20:10
-
Just run into a similar issue. I'm writing on an Org file since 2 hours and suddenly the whole buffer is empty and so is the undo history. Because I have auto-save enabled the saved file and the backup file are empty as well. I use Git to "backup" but in this case I haven't yet because I'm still in the midst of working on this file. – Günter Zöchbauer Mar 14 '20 at 14:43
-
@wvxvw thanks a lot. I could recover the content using this method \o/ – Günter Zöchbauer Mar 14 '20 at 14:59
2 Answers
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.

ctrl-alt-delor
- 121
- 8
-
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.

chiangxinyu
- 81
- 3
-
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 08: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 08: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 09:28