9

I like to have my browser history span years back so I can look at things which may have interested me a long time ago. To pursue this desire, I have set Safari to remove history items "manually" under the General tab in the Preferences. I have done the same thing for download list items. My intent was (and is) to not remove history items ever and to keep Safari from doing it automatically.

This seemed to be working fine for a while, and I still have history which goes back more than a year. However, I have recently noticed that the oldest days in my history are disappearing. At first I wasn't sure, but after conducting some tests I am sure. It seems to happen randomly and infrequently. I think that the Safari window also loses focus when it happens.

I am not sure how or why this is happening. The only thing I can think of is that there may be some hard-coded limit in Safari itself. Or perhaps it purges old history items when it reaches a memory limit.

I see that my History.db file is 80MiB in ls output:

  -rw-r--r--    1 my_username staff  80M Dec 29 13:02 History.db

Is 80MiB some sort of implicit limit for Safari?

Another troubling facet of this issue is that I cannot export my Safari history to another browser. Both Chrome and Firefox refuse to import anything from Safari except bookmarks. Moreover, I do not have many backups of my Safari history. Although, backups would not help too much anyway since a backup would lack my recent history.

So how can I get Safari to stop losing my oldest history items?

Some environment info:

My Safari version is currently 11.0.2 on macOS 10.13.2. Also, I am not using iCloud integration with Safari.

EDIT:

At the time of the bounty on this question, I will also consider accepting answers which offer a way to export my history to another browser (preferably Firefox or Chrome).

6
  • Have you checked for any similar question on here ? Such as : apple.stackexchange.com/q/178969/237687
    – Solar Mike
    Commented Dec 29, 2017 at 20:42
  • A similar question was given the suggestion of a chron script to store each day / week copied to a separate file as backup... can’t find it at the moment tho’.
    – Solar Mike
    Commented Dec 29, 2017 at 21:47
  • @SolarMike That is an interesting idea. I certainly would like to know more about it.
    – GDP2
    Commented Dec 30, 2017 at 1:42
  • Well, have search you may find it before me...
    – Solar Mike
    Commented Dec 30, 2017 at 10:06
  • @SolarMike I did not find the suggestion about cron, but I can confirm that the advice in the question you linked to does not work. I still lose history even after setting HistoryAgeInDaysLimit to 999999.
    – GDP2
    Commented Dec 30, 2017 at 19:00

2 Answers 2

5
+50

This is size limit imposed by Safari.

A sqlite database can obviously be larger than 80M; it is only limited by the amount of available storage space, but technically it has an upper file size limit of about 140TB

Other developers have noted that in (older versions of) Safari, the limit is capped at 50GB. It's reasonable to assume that this limit has been increased in subsequent releases of macOS/iOS/Safari.

It also stands to reason that this size limit is imposed by (Apple) Safari because, by default, it is configured to synchronize with iCloud to other Apple devices many of which are constrained by storage availability (iPhones and iPads, for example).

We also know that iCloud's basic (free) storage allotment is 5GB and this must account for much more than browsing history. Things like files, settings, device backups (where applicable) keychains, notes, etc. must be allocated space. Synchronization of these items is set by default by Apple.

It wouldn't make much sense to allow an unlimited history where History.dbcould outstrip the capacity of iCloud/iPad/iPhone.

Even though you're not using iCloud integration, the average user does and Apple will architect it's products around this premise and design their products accordingly.

Extracting Your History

You can pull your history items out of the History.db file with this (very) simple sqlite3 script

Create a "commands.txt" file and populate it with the following commands:

.mode csv
.once history.txt
select visit_time, title, url from history_visits inner join history_items on history_items.id = history_visits.history_item;

Then issue the command

sqlite3 History.db < commands.txt

This will create a CSV file called history.txt containing the time, title and URL of the history items. This assumes you are in the ~/Library/Safari directory. Keep in mind that the date/time of your history item will be in epoch time (although the epoch is different in this case) and will need to be ultimately converted.

12
  • This is useful information and it's good to know that this limit is imposed by Safari on purpose. At least it's not some crazy bug. Yet, I would still prefer a way to get around this limitation so that I can still use Safari. But if no better answer appears, I guess this will be the best one.
    – GDP2
    Commented Jan 4, 2018 at 18:47
  • Well, I just tried your script since no new answers have appeared. Strangely, it doesn't seem to work. The resultant history.txt file is completely empty.
    – GDP2
    Commented Jan 10, 2018 at 6:51
  • If you manually enter the select command in sqlite3 do you see anything?
    – Allan
    Commented Jan 10, 2018 at 11:22
  • No, there is no output when I do that either.
    – GDP2
    Commented Jan 10, 2018 at 17:50
  • Just so we're on the same page.... sqlite3 History.db, then select * from history_items; Let me know what you get.
    – Allan
    Commented Jan 10, 2018 at 17:53
0

Simple answer, no you cannot.

I suggest you use Chrome and import your data with these steps:

  1. install and start Chrome (close Safari)
  2. Click on the 3 dots on the Top-right corner
  3. Drag your cursor to "Bookmarks" then click on "Import Bookmarks and Settings"
  4. You'll see 4 options, it is Select items to import: "Browsing history" "Favorites/Bookmarks" "Saved passwords" "Search engines"
4
  • This is all I see when I try to import things from Safari to Chrome.
    – GDP2
    Commented Jan 4, 2018 at 3:35
  • Can you please elaborate on how this answers the question?
    – nohillside
    Commented Jan 4, 2018 at 7:54
  • 1. Chrome cannot import Safari history as of now 2. Chrome also deletes history older than 90 days. 3. Best alternative is FF which gives user the ability to set the expiry date/number superuser.com/questions/1635171/… but that's not helpful for this question
    – anki
    Commented Apr 29, 2021 at 6:39
  • Thanks, Sherlock; You're three years late for the discussion.
    – SG pro
    Commented Apr 29, 2021 at 8:00

You must log in to answer this question.

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