davidhq
davidhq

Reputation: 4760

Where does Firefox save currently open tabs on disk

For example Chrome saves here: ~Library/Application Support/Google/Chrome/Default/Current Tabs and Safari here ~/Library/Safari/LastSession.plist. What about Firefox? I found this folder ~/Library/Application Support/Firefox/Profiles/sewzwkcf.default but I cannot spot the right file.

Upvotes: 6

Views: 6682

Answers (2)

papo
papo

Reputation: 1969

2023-08: The 8 yrs old answer is basically still valid. *.js (JSON) and *.bak files are now compressed and using *.jsonlz4 and .baklz4 extensions. This change happened sometime between 2017-09 and 2019-07.

There is a FF bug (described below), which someone searching for this Question probably just encountered. You can still fully recover manually.

Various "Opened Tabs State" files

To sum what the blog article mentioned in edandaniel answer is saying,
Mozilla does this. Every...

  • 15 sec: sessionstore-backups/recovery.jsonlz4 -> sessionstore-backups/recovery.baklz4,
    new sessionstore-backups/recovery.jsonlz4

  • Mozilla exit: new sessionstore.jsonlz4

  • Mozilla start: sessionstore.jsonlz4 -> sessionstore-backups/previous.jsonlz4

  • Mozilla start after upgrade: sessionstore.jsonlz4 -> sessionstore-backups/upgrade.jsonlz4-20230805021307

Seems bulletproof, but there is at least below mentioned special case when it will fail.

To recover

Search for a sessionstore file (from locations and filenames above), which is bigger than 1kB, has recent modified date, copy it aside, exit Mozilla, copy/rename the copied file to sessionstore.jsonlz4, start Mozilla.

You can use lz4json (apt install lz4 lz4json) to unzip and inspect each file.
Usually when the file is lost without Mozilla being able to find the backup, it's re-created and while empty has about 900 bytes size.

Current Mozilla bug

The bug in Mozilla here described will cause a loss of opened tabs state. But there is a way to manually recover the previous state.
It's possible these steps can be used for a different situation.

When Mozilla is upgraded, but not restarted, then later properly exited, then started again and subsequently crashed, while no new tabs were opened or closed.

Why:
sessionstore.jsonlz4 is not present while Mozilla is running, sessionstore-backups/recovery.*lz4 are not created without a change to tabs (I suppose), and sessionstore-backups/previous.jsonlz4 is present and OK, with identical content as sessionstore-backups/upgrade.jsonlz4-20230805021307, but is not used to recover lost tabs state. On sequential Mozilla start it is overwritten with the new, empty one.

But there still is sessionstore-backups/upgrade.jsonlz4-20230805021307 (20230805021307 part is an example), which can be used to recover manually, as described above.

Upvotes: 1

edandaniel
edandaniel

Reputation: 76

Since version 33, Firefox saves the open session in /sessionstore-backups/recovery.js, inside your Profile Folder.

Yoric says in this blog post:

• sessionstore-backups/recovery.js
contains the state of Firefox ≤ 15 seconds before the latest shutdown or crash...
...
All these files use the JSON format.

You can see all your open tabs, windows and session info in just a single file, being updated every few seconds.

Upvotes: 6

Related Questions