Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restore Firefox bookmark files from SQLite files?

I have two files that I managed to restore from a Firefox installation under Windows XP. The first one is urlclassifier3.sqlite and the second one is urlclassifier.pset.

I understand that those files contain the actual bookmarks for an installation of Firefox, under a user profile, given that the profile is .\Mozilla\Firefox\Profiles\akcum27.default. How can I restore the bookmarks from those files?

The big one is the .sqlite file, at around 56 kilobytes.

like image 418
jfmessier Avatar asked Aug 02 '12 00:08

jfmessier


3 Answers

A query that will actually work (on Windows as the question is about) is:

sqlite3 places.sqlite "select '<a href=''' || url || '''>' || moz_bookmarks.title || '</a><br/>' as ahref from moz_bookmarks left join moz_places on fk=moz_places.id where url<>'' and moz_bookmarks.title<>''" > t1.html

This presumes:

  • Using the Windows command-line (CMD)
  • The current directory is where file places.sqlite is (there is one for each Firefox profile, with the default profile often named "default" or "default-release")
  • SQLite 3 (executable sqlite3) is installed and is in the path (environment variable PATH)

Sample generated HTML:

<a href='http://www.wunderground.com/hurricane/'>Tropical weather</a><br/>
<a href='http://www.dmi.dk/vejr/maalinger/radar-nedboer/'>DMI, Radar</a><br/>
<a href='http://www.skyandtelescope.com/observing/objects/planets/3304091.html?page=1&c=y'>Transit Times of Jupiter's Great Red Spot - Planets - SkyandTelescope.com</a><br/>
<a href='https://www.quora.com/What-is-the-most-misspelt-word-in-the-English-language'>(951/25) What is the most misspelt word in the English language? - Quora</a><br/>
<a href='http://www.eevblog.com/2015/06/16/eevblog-754-altium-circuit-maker-first-impressions/'>EEVblog #754 - Altium Circuit Maker First Impressions | EEVblog - The Electronics Engineering Video Blog</a><br/>
<a href='https://www.arduino.cc/en/Main/ArduinoBoardUno'>Arduino - ArduinoBoardUno</a><br/>

Notes

  • The result is not ordered as in the Firefox Bookmarks menu, and there are some extra entries, both http/https ones, like "About Us" and some non-http/https ones.

  • It also works on Linux, but

    • if Firefox is running, the result is "Error: database is locked" (for the Firefox profile in question, if more than one Firefox profile is used. E.g., use about:profiles in the address bar to explore the profiles)

    • SQLite 3 is not installed on Ubuntu systems by default, but it can be installed with:

      sudo apt install sqlite3
      
    • This was verified with Ubuntu 18.04 (Bionic Beaver) and Ubuntu MATE 20.04 (Focal Fossa)

  • It has been known to work on (reverse version order):

    • Firefox 97.0 (2022-02-08) on Ubuntu 18.04 (Bionic Beaver)

    • Firefox 97.0 on (2022-02-08) Ubuntu MATE 20.04 (Focal Fossa)

    • Firefox 83.0 on (2020-11-17) Ubuntu MATE 20.04 (Focal Fossa)

    • Firefox 57.0.2 (2017-12-23) on Windows 10. Quantum. 64-bit version 64-bit)

    • Firefox 46 (2016-04-26)

    • Firefox 40 on Windows (approximately. 2015-08. Before Quantum).

like image 158
Peter Mortensen Avatar answered Nov 03 '22 00:11

Peter Mortensen


Bookmarks are held in file places.sqlite, not urlclassifier. You can try to replace the file in your current installation with that. Make sure Firefox is closed. If that doesn't work:

You might want to install the Firefox addon "SQLite Manager" and then use the addon (use the Alt key to open the addon menu in Firefox) to open the file places.sqlite from your old install. Right click Tables -> moz_bookmarke on the left hand side and click "export table"

Export your table as XML or SQL and then open file places.sqlite from your current install and click Database -> Import Table and import it in the similiar same way you exported.

like image 24
gmlime Avatar answered Nov 03 '22 01:11

gmlime


You can also replace the places.sqlite file in the Firefox profile folder, and then, since the database may not be retrieved by Firefox, you can open another web browser (Chrome, Edge, etc.) and import your Firefox bookmarks from this new browser (most of the browsers can import Firefox bookmarks). Finally, from Firefox you can import the bookmarks again from this third-party web browser.

like image 25
Thibaut Avatar answered Nov 02 '22 23:11

Thibaut