Over the years, we’ve provided a lot of tips on how to recover space on your Mac, one of which is to delete your browsing history in Safari. That’s all fine and good, and it will definitely open up megabytes of space, but what if that browsing history was your only link to an important web site or page? Today we’re going to look at how to recover a deleted Safari browsing history.
Restore From Time Machine
To restore your deleted Safari history, you’re going to need a Time Machine backup or another backup file from before the date that you deleted your browsing history. (note that this isn’t always the case on public machines like those at a library or school). If the Mac is only used by you or a small group of users, and you have Time Machine backups running constantly, then this is the method to use.
1) If Safari is currently open, quit out of it. Next, click and hold on the Finder icon (the smiling face at the far left side of the Dock) until the pop-up menu appears, then select “New Finder Window”.
2) A Finder window appears on the screen. Go to the menu bar, select Go > Go to Folder, type in ~/Library/Safari (see screenshot below), and then click the Go button.
3) This opens the Finder window to the ~/Library/Safari directory.
4) Make sure that the Time Machine icon appears in the right side of your Mac menu bar. If it doesn’t, launch System Preferences, then Time Machine, and then check the box next to “Show Time Machine in menu bar”
5) In the open Finder window, find the file named “History.db”. Click it once to select it, then select “Enter Time Machine” from the Time Machine menu (see screenshot below).
6) Once Time Machine is open, a list of all backups of the History.db file appears (see screenshot below). You’ll want to use the up arrow to go “back in time” to an earlier date before you deleted your Safari browsing history, and then click the Restore button. Note that if you’re looking from a Safari browsing history from a long time ago, it’s possible to use the slider on the far right of the Time Machine screen to go back months or years.
7) Once Time Machine has restored the “History.db” file, launch Safari.
8) From the menubar for Safari, select History > Show All History. A grid-like list of your browsing history appears in a browser window, showing all of the visits you’ve made on your journey around the web (see image below).
One comment about that History.db file. It’s actually a SQLite database file and can be queried or searched with almost any SQL database tool, including this free app — DB Browser for SQLite. However, it’s much easier for most users to simply to use the search bar in the upper right corner of the History window to search for a particular item.
If you don’t have a Time Machine backup or another backup from an earlier time, there’s really no way to recover your browsing history. This is yet another reason why we constantly recommend getting an inexpensive external drive, hooking it to your Mac, and then setting up Time Machine to back up the device continuously.
A Note About DB Browser for SQLite
Curious about your browsing history? For example, perhaps you’d like to know how many times you’ve visited a specific web page. The app discussed in the previous section — DB Browser for SQLite — is a handy tool for getting some information from the History.db file that might be useful.
After downloading and installing DB Browser for SQLite, launch the app, find the History.db file (the first part of this article shows you how to do this), then drag it to the DB Browser window. The file opens in the Database Structure view; what most users want to do is browser the data stored in one of the SQLite tables.
As an example, I’ve opened the History.db file in DB Browser, then selected the history_items table from the Table pop-up list. The screenshot below shows the contents of that table, which include an ID number, the URL of a visited site, a “domain_expansion” for each site, and various other columns in this table.
I don’t recommend using DB Browser for SQLite for anything other than just browsing the History.db file unless you really know what you’re doing! If you decide to play with deleting records, be sure to have a backup of History.db in case you corrupt it.