I use Sessions to keep track of browsing sessions in Safari. I was having some trouble with invalid cookies and I cleared my web history. Now all of my saved Sessions are gone. Is there any way to recover the data? Where does Sessions store it's data? I may have a backup.
2 Answers
If you go to Sessions "Help" (in the gear menu), there are two questions relevant to your issue:
Why did my saved sessions disappear when I reset Safari or cleared its history?
The option to remove website data, available when either resetting Safari or clearing its history, will delete extension data without warning. Some third-party cache cleaners may do the same. It is recommended to take care when using these tools, as any data so deleted can only be recovered from a backup.
and more importantly for you:
How do I recover Sessions data from a Time Machine or other backup?
If you are familiar with the command line, try using the
sessions-export
script. This is the recommended procedure. Alternatively, it is possible to physically replace the database file with a backup. The .db file under the directory~/Library/Safari/Databases/safari-extension_yoo.david.sessions-deub45nr9t_0/
can be replaced by a recovered file if the latter is renamed to match the file it replaces.
So, if you have a backup, it should be as easy as a copy and maybe a rename.
-
Hello Travis, welcome to Ask Different. Thank you for your answer. I've added the relevant sections from the "Sessions" plugin help to make the answer more useful and a better reference in the future (as stated here: apple.stackexchange.com/help/how-to-answer " Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.").– jaumeOct 10, 2018 at 11:15
Sessions seems to store its data in the browser's javascript database which, per this stackoverflow posting, is in ~/Library/Safari/Databases
.
In fact, I see a directory in mine called something like safari-extension_yoo.david.sessions-<random number>
. The contents appear to be an SQLite database:
$ file *
0000000000000001.db: SQLite 3.x database, last written using SQLite version 3008010
0000000000000001.db-shm: data
0000000000000001.db-wal: SQLite Write-Ahead Log, version 3007000
Using sqlite3
per the instructions here and here, I can see what looks to be interesting data:
$ sqlite3 *.db
SQLite version 3.16.0 2016-11-04 19:09:39
Enter ".help" for usage hints.
sqlite> .tables
__WebKitDatabaseInfoTable__ tabs
favorites tabs_windows_sessions
sessions windows
sqlite> select * from sessions;
1|1381010647|◆ 2013-10-05 18:04:04
2|1381011556|◆ 2013-10-05 18:19:16
3|1381283711|◆ 2013-10-08 21:55:10
4|1381419556|◆ 2013-10-10 11:39:15
...