34

Possible Duplicate:
How to recover form information for a webpage in Firefox

I typed a couple of paragraphs on a discussion board, but when I clicked the submit button, the site was undergoing (un)scheduled maintenance, and the back button decided to refresh the page, sending my paragraphs into oblivion.

A quick web search revealed that Lazarus provides form recovery for Firefox. However, installing a plugin requires restarting Firefox, and even after restarting Firefox (which I haven't done yet), Lazarus can't recover forms it hasn't backed up yet.

Now that the horse is out of the barn, I want to do the impossible: restore some or all of the text I typed, without restarting my browser.


Edit: I should clarify. Lazarus is a wonderful solution for preventing future form data loss. This question is for people who have already navigated away from their form and lost its contents, but hope there is some way to salvage the situation. My solution was to get a core dump of the process and grep through it, but there might be a layman's way to do it (for example, somehow get Firefox to load the cached version of the previous page). Thus, solutions that only solve the problem in the future, without addressing the present, are off-topic in this question.

5
  • 1
    I think you've answered your own question here...
    – user1931
    Jan 22, 2011 at 9:03
  • 2
    @John T: Indeed. I'm just creating Google fodder for others with the same problem, but if anyone has any better suggestions, they are certainly welcome.
    – Joey Adams
    Jan 22, 2011 at 9:16
  • 10
    This is not an exact duplicate. The referenced question's top answers require installing a plugin, which does not help the user if they already lost the form.
    – Joey Adams
    Apr 30, 2012 at 2:15
  • I have run into the same situation. A solution would be very nice. Even against future form data loss, I am also looking for a solution. Lazarus is promising, but he has the slight weakness of not working at all. Apr 15, 2014 at 10:07
  • 1
    superuser.com/questions/512669/… is relevant and provided a working solution for me via the Web Developer tools technique.
    – pbhj
    Apr 7, 2015 at 22:15

2 Answers 2

61

Do not restart your browser or press the back button!

On Linux:

This solution is hit or miss, and works on Linux. In short: dump the memory of the Firefox process, and search through it for fragments of your text. It's ugly, but it's your last resort.

First, dump core using the gcore utility, which requires gdb (the GNU debugger) to be installed:

$ ps -e | grep firefox
 7089 ?        00:02:23 firefox
$ gcore 7089
[New Thread 0xa8ffeb70 (LWP 8924)]
[New Thread 0xb25feb70 (LWP 8531)]
[New Thread 0x9d7feb70 (LWP 8527)]
... snip ...
[New Thread 0xb5ffeb70 (LWP 7099)]
[New Thread 0xb67ffb70 (LWP 7098)]
[New Thread 0xb72f8b70 (LWP 7097)]
Saved corefile core.7089

Note that a core dump may take several hundred megabytes of disk space.

If it succeeded, you can now breathe a sigh of relief. If your text was lingering in memory by chance, it has been captured in the core dump.

Now, try to remember a phrase from your essay (for example, "a profound effect"), and use grep to see if it's present in the document:

$ grep 'a profound effect' core.7089 
Binary file core.7089 matches

If you get "Binary file ... matches", good, it's there! If not, try more phrases. If all of your grep attempts produce empty output, then your essay is probably gone forever, and there is nothing you can do about it. (You can try grep -R 'a profound effect' ~/.mozilla, but I doubt it will work)

Assuming you do get a match, the next task will be to slice out pieces of the core dump containing the text you're looking for, and use less to look at it visually:

$ grep -B 20 -A 20 -a 'a profound effect' core.7089 > /tmp/out
$ less /tmp/out

(You could omit the first line and just say less core.7089, but I've found that less tends to blow up in memory usage when searching through such a large binary file.)

Now, type /a profound effect, hit enter, wait, and page down until you see something recognizable:

alt text

Bam! If you don't like this result, see if there are any others by typing 'n'. Also, be sure to proofread the garbage so you don't end up posting:

my mind will often generate mush express ideas in that language.

I imagine it gets clobbered like this because the memory holding your essay fragments is no longer allocated and gets trampled by subsequent allocations.

On Windows:

The procedure is the same. First, create a core dump of Firefox. This can be accomplished in the Task Manager. In English, the menu entry is Create Dump File.

Dumping the firefox core

Dumping takes a few seconds.

Core dump location

Then, use a hex editor like http://mh-nexus.de/en/hxd/ to open the dump, and search for the lost text.

HxD for searching the dump

5
  • 3
    Worked for me on Windows even after the back button was pressed. It's even more laborious now given many processes created by the Firefox, but after saving all of them and using a tool (FAR manager) to search across multiple encodings simultaneously it worked (UTF-16 little endian was the result in my case). Jan 12, 2019 at 1:06
  • 1
    Worked with chromium on Linux. Had to refresh the page to figure out which process the page was by monitoring htop (chrome seems to create a lot of threads).
    – passerby51
    Mar 25, 2019 at 22:44
  • 1
    I didn't know Windows has a memory dump feature xD. In my language is "Crea file di dettagli" (more or less the italian form "create details file"). Sometimes translations are misleading. Thank you ^^ Jan 3, 2021 at 17:40
  • 1
    ps -e | grep Web | awk '{print $1}' | xargs gcore produced 90 GB, grep took 5 minutes (gcore took longer) to find nothing. May be my own fault for pressing back and doing some stuff in Firefox before figuring this out.
    – dreua
    Jan 20, 2023 at 12:09
  • Nope, just tried again with ps -eo pid,args | grep firefox | awk '{print $1}' | xargs gcore which should catch all the Firefox processes, got no results. (There were some scattered page contents, bookmarks and so on but not the valuable form entry.) I hereby declare this answer not functional any more. If anyone recently had success with it: Please do report.
    – dreua
    Aug 25, 2023 at 20:54
2

First thing -- forms are usually not cached. So, whatever you submitted is gone to the site and if it dropped it you are done; you need to re-type it.

Lazarus uses a SQLite DB to store your form data (of course, only after it is installed).

ps: the core-dump is a cute attempt to do the needful, however I wonder if there is a cost-to-effort benefit on that (this would be more useful as a spyware/malware technique -- no offense to Joey here).

4
  • 1
    Actually, the core dump technique turned out to be easier than I expected.
    – Joey Adams
    Jan 22, 2011 at 9:42
  • @Joey, It did for you and then you declared it the solution for your own problem. I wonder how well it will fare for everyone hitting the same problem -- should they install things like Lazarus or wait to get a core-dump and try their luck? If so, it would be worthwhile to keep in mind how the two things work.
    – nik
    Jan 23, 2011 at 5:21
  • 1
    Actually, the core dumped technique was very useful to me, and was very simple to do.
    – lvella
    Oct 17, 2013 at 20:36
  • 2
    Against future form data loss, Lazarus is promising, but he has the slight weakness of not working at all. Apr 15, 2014 at 10:13

Not the answer you're looking for? Browse other questions tagged .