Where does Safari store open windows ? They reappear after a restart of the Mac or Safari or after a crash of Safari. I lost them somehow and hope I can reinstate them from my backup
I think it is in ~/Library/Containers/com.apple.Safari/Data/Library/Saved Application State/com.apple.Safari.savedState
.
Update: This is wrong, see reply Where does Safari store currently open windows - #3 by mschmitt below
Note that this may appear in the Finder as ~/Library/Containers/Safari, due to what I consider to be a bug. I reported this to Apple.
Thereās more to it than this. Yesterday I accidentally closed Safari, so I restarted it to get back the window ā I have Settings > General > Safari opens with: All windows from last session. The result was that it did reopen the window tabs, but it froze, and then crashed. And when I restarted Safari again, this time that tabs were all blank. It had lost the URLs for the tabs.
So, I quit Safari and replaced the Saved Application State folder from an older version. It didnāt work; it just opened a window but not with the last used web pages. Trying History options to reopen recently closed / last closed tab / all windows didnāt work either.
I also notice that when you quit Safari, the Saved Application State folder is deleted. So, which windows were used in the last session must be stored elsewhere.
Iām going to guess SafariTabs.db. I believe most, if not all, browsers switched to using databases for storing history long ago for performance reasons.
(trying it outā¦)
Yes, it works! I quit Safari, restored the three ~/Library/Containers/com.apple.Safari/Data/Library/Safari/SafariTabs.db*
files from TimeMachine, and then when I restarted Safari my tabs were back.
@mschmitt You are describing a scenario that is almost identical to mine as far as the original event that took place is concerned. Iām going to replace the db files, but first, hereās something bizarre. How can there be three folders with identical names āSafariā? Looking with CMD+i their real names are
- com.apple.Passwords.MenuBarExtra
- com.apple.Passwords-Settings.extension
- com.apple.Safari
Only #3 contains the word āSafariā in its name and the folder has the db files weāre after.
The Finder is lying to you. I first posted about this in July 2023: Finder changes display of Library > Containers.
You can see the true folder name if you drag one of the Safariās to a Terminal window. On my machine there are two: com.apple.Safari and com.apple.Passwords-Settings.extension.
Rich Siegel (Bare Bones Software) told me āThe illusory file name display for application containers in the Finder is a misfeature that was introduced in macOS 12ā.
I reported this to Apple in May 2024. My feedback status is still Open, with no response from Apple. Maybe we need more people to report this as an issue.
For me this doesnāt work.
May only work if you have Safari set to re-open windows from the last session. But even if they donāt reopen automatically, since youāre restoring the history Iād think you could then use the History menu option to reopen all windows.
Safari was always set to āre-open windows from the last sessionā. The last session was already overwritten, I fear the history is my last resort.
Eventually I asked ChatGPT to analyse the Safari.db file for me. Iām not a coder, but gave so many prompts that it produced a csv file for me that rescued some 20 URLs for me. I expected about 40, but better half than nothing. The tool ChatGPT suggested first couldnāt open the file, but I was guided step by step through some terminal commands that did in the end give me something useable.