Reading "jsonlz4" bookmarkbackup files

User Help for Mozilla Firefox
antofthy
Posts: 14
Joined: April 12th, 2012, 5:11 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by antofthy »

Continuing my own saga with dealing with firefox obtuse data storage, I gave up on the now USELESS jsonlz4 backup files.

Instead I spent time trying to figure out using sqlite3 and the SQL database language!! Arrgghhhh....

The following will search the places.sqlite file for a bookmark with a specific string.

bookmark="string_to_find"
sqlite3 places.sqlite \
"SELECT moz_bookmarks.title, moz_places.url
FROM moz_bookmarks
JOIN moz_places ON moz_places.id=moz_bookmarks.fk
WHERE moz_bookmarks.title LIKE '%$bookmark%'
;" | tr '|' '\n'

It seems my bookmark corruption was because places stores the bookmark 'name' in a seperate table to the bookmark 'url', linking the two using a 'id number'. In my case that ID number was incremented causing every bookmark name to be incorrectly linked to the associated URL.
Basically a absolute mess. The data was there, just name-url pairing no matching!

Thank god I had my oldest bookmarks (the ones most effected) in Chrome, and was able to pick up and move most of the de-synced bookmarks one bookmark at a time between the two browsers.

Mozilla.... Make your 'text backup' storage more user friendly... because when the chips are down... firefox is not the solution!
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Reading "jsonlz4" bookmarkbackup files

Post by therube »

I must be doing something wrong?

Code: Select all

set bookmark=Zine
sqlite3  places.sqlite  "SELECT moz_bookmarks.title, moz_places.url FROM moz_bookmarks JOIN moz_places ON moz_places.id=moz_bookmarks.fk WHERE moz_bookmarks.title LIKE '%bookmark%' ;"  |  tr  "e"  "X"

Would have suspected I'd get something like, mozillaZinX, but I'm not getting any output, or do I need to set bookmark to the entire .title?

or do I need to set bookmark to the entire .title?

Ah, yes, that's it.

Code: Select all

set bookmark=mozillaZine
sqlite3  places.sqlite  "SELECT moz_bookmarks.title, moz_places.url FROM moz_bookmarks JOIN moz_places ON moz_places.id=moz_bookmarks.fk WHERE moz_bookmarks.title LIKE '%bookmark%' ;"  |  tr   "\|"   "\r"


Code: Select all

http://www.mozillazine.org/
http://www.mozillazine.org/
http://www.mozillazine.org/
http://forums.mozillazine.org/
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
pijani
Posts: 3
Joined: April 9th, 2015, 10:02 am

Re: Reading "jsonlz4" bookmarkbackup files

Post by pijani »

Hi guys.

I;ve saved .jsonlz4 backup files from my last mozzila on XP. I tried them there, and I could get backup from them.

Now I've installed 8.1 on a new PC, and Mozzila does not reckognize them. I know about export option, but I didn't export for quite some time, and I would like to save all bookmarks.

I've copy-pasted files to the profiles folder, where new backup files with .json extension are.

I am not sure how can I make mozilla read those .jsonlz4 files...

Thank you
pijani
Posts: 3
Joined: April 9th, 2015, 10:02 am

Re: Reading "jsonlz4" bookmarkbackup files

Post by pijani »

Edit: I have places.sqlite file, but I don;t know what to do with it
pijani
Posts: 3
Joined: April 9th, 2015, 10:02 am

Re: Reading "jsonlz4" bookmarkbackup files

Post by pijani »

I've got it (thnks to you guys and earlier posts from other threads) just copy-paste all three files into my profile folder, whom I found typing %APPDATA%\Mozilla\Firefox\Profiles in search

again, thank you very much :)
User avatar
dickvl
Posts: 54161
Joined: July 18th, 2005, 3:25 am

Re: Reading "jsonlz4" bookmarkbackup files

Post by dickvl »

Here is some code to decompress a compressed .jsonlz4 backup that you can run in the Browser Console.
You can toggle devtools.chrome.enabled to true on the about:config page to enable the command line.
https://developer.mozilla.org/Tools/Bro ... mmand_line
http://mxr.mozilla.org/mozilla-release/ ... ackups.jsm

New version that uses a file picker (thanks to jscher2000).
Paste the code in the command line and press the Enter key to evaluate the code.

Code: Select all

var {classes:Cc, interfaces:Ci, utils:Cu} = Components;
async function decompressFile(oFilePath,nFilePath){
let jsonString = await OS.File.read(oFilePath,{compression:"lz4"});
await OS.File.writeAtomic(nFilePath,jsonString);
}
var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter(".*LZ4* Compressed Files","*.*lz4*");
fp.appendFilter(".LZ4 Compressed Files","*.lz4");
fp.displayDirectory=fu.File(OS.Path.join(OS.Constants.Path.profileDir,""));
fp.open((aResult) => {
if(aResult == Ci.nsIFilePicker.returnOK){
if(fp.file.exists()&&fp.file.isFile()&&fp.file.isReadable()){
var oldfile=fp.file.path;
var newfile=oldfile+".json";
try{
decompressFile(oldfile, newfile);
console.log("Saved as: \"" + newfile + "\"");
}catch(err){console.log(err);}
}
}else{console.log("<canceled>");}
});


Original version that uses file paths.

Code: Select all

var {utils:Cu} = Components;
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
var backupFolderPath = prompt("Path to bookmarkbackups folder","");
var FileName = prompt(".jsonlz4 file to restore","").split(".")[0];
function decompressBookmarksFile(oFilePath,nFilePath){return Task.spawn(function* () {var jsonString = yield OS.File.read(oFilePath,{ compression: "lz4" });yield OS.File.writeAtomic(nFilePath, jsonString);})}
if(FileName){
var oldFilePath = OS.Path.join(backupFolderPath, FileName+".jsonlz4");
var newFilePath = OS.Path.join(backupFolderPath, FileName+".json");
decompressBookmarksFile(oldFilePath,newFilePath);
console.log("Saved as: "+ newFilePath);
}
Last edited by dickvl on July 28th, 2020, 1:42 am, edited 4 times in total.
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Reading "jsonlz4" bookmarkbackup files

Post by therube »

@pijani, are you really running FF 19?
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
lolaiii
Posts: 298
Joined: October 16th, 2004, 6:23 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by lolaiii »

You wrote:
If you have a backup of places.sqlite, just copy that backup file into your existing profile. This is the actual bookmark file.

My places.sqlite file appears to be void of my bookmarks, therefore, my only hope is extracting them from a backup file. Does anybody have the answer to how to uncompress .jsonlz4 files in order to extract backed up bookmarks?
lolaiii
Posts: 298
Joined: October 16th, 2004, 6:23 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by lolaiii »

You wrote:
If you have a backup of places.sqlite, just copy that backup file into your existing profile. This is the actual bookmark file.

My places.sqlite file appears to be void of my bookmarks, therefore, my only hope is extracting them from a backup file. Does anybody have a simple answer re how to decompress .jsonlz4 files in order to extract backed up bookmarks? I don't do code; I don't understand what a browser console is or how to use code.
kreemoweet
Posts: 778
Joined: December 30th, 2009, 11:25 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by kreemoweet »

lolaiii wrote: ... my only hope is extracting ...


You don't need to "extract" anything. Just use Firefox's built-in bookmark manager to "restore" your bookmarks from the .jsonlz4 file.
cf5710988
New Member
Posts: 1
Joined: September 8th, 2015, 9:40 am

Re: Reading "jsonlz4" - Create another Windows User

Post by cf5710988 »

Don't want full restore. One computer died. I only needed one bookmark from the jsonlz4 backup for another computer. Restoring is not an option because it would overwrite all new bookmarks with the old backup. I created a new Windows 8 user, opened Firefox for that user, Restored from the jsonlz4 file, found the bookmark and copied it to Firefox in the main Windows account.

At this point I could Export to HTML and do what I wanted with that, including selectively extracting bookmarks to put in another place. I assume this wold work with other OS.
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Reading "jsonlz4" bookmarkbackup files

Post by therube »

(Didn't even need to create a new Windows user, you could have just created a new FF Profile, & used that Profile to do the restore & copy out your wanted bookmark. In any case, you come to the same result.

Was looking just the other day trying to find something new on the lz4 [decompressor] end but my searches weren't very fruitful.)
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
antofthy
Posts: 14
Joined: April 12th, 2012, 5:11 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by antofthy »

I do not believe there has been any progress on this. No lz4 decompression tool is generally available, so no good way outside of firefox to get at the .jsonlz4 file contents.

I have also had too many problems with using the firefox places.sqlite, the biggest one being something I discussed before, in that the 'id' link between the two takes (one holding the bookmark title the other the bookmark url) goes out of alignment causing practically all the bookmarks title-urls to be mis-matched.

The point however is now moot. I have switched to Google Chrome, which uses a standard and much simplier json bookmarks file. Not only that it is json with appropriate whitespace and indentation, which makes the file directly readable, without needing reformating, and open to simple text searching (AKA grep, perl, and hundreds of other utilities)!
syryos
New Member
Posts: 1
Joined: September 22nd, 2015, 1:51 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by syryos »

I cannot get oen of the codes working in Firefox 40.0.3 console.
Message always is: TypeError: Cu is undefined . Please can anyone advice?


dickvl wrote:Here is some code to decompress a compressed .jsonlz4 backup that you can run in the Browser Console.
You can toggle devtools.chrome.enabled to true on the about:config page to enable the command line.
https://developer.mozilla.org/Tools/Bro ... mmand_line
http://mxr.mozilla.org/mozilla-release/ ... ackups.jsm

New version that uses a file picker (thanks to jscher2000).
Paste the code in the command line and press the Enter key to evaluate the code.

Code: Select all

var {classes:Cc,interfaces:Ci,utils:Cu} = Components;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("Bookmark Backup Files", "*.jsonlz4");
if (fp.show() == Ci.nsIFilePicker.returnOK) {
 var file = fp.file;
 if (file.exists() && file.isFile() && file.isReadable()) {
  var oldFile = fp.file.path;
  var newFile = oldFile.replace(".jsonlz4", ".json");
  Cu.import("resource://gre/modules/Task.jsm");
  Cu.import("resource://gre/modules/osfile.jsm");
  function decompressBookmarksFile(oFilePath,nFilePath){return Task.spawn(function* () {var jsonString = yield OS.File.read(oFilePath,{ compression: "lz4" });yield OS.File.writeAtomic(nFilePath, jsonString);})}
  decompressBookmarksFile(oldFile,newFile);
  console.log("Saved as: "+ newFile);
 }
}


Original version that uses file paths.

Code: Select all

var {utils:Cu} = Components;
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
var backupFolderPath = prompt("Path to bookmarkbackups folder","");
var FileName = prompt(".jsonlz4 file to restore","").split(".")[0];
function decompressBookmarksFile(oFilePath,nFilePath){return Task.spawn(function* () {var jsonString = yield OS.File.read(oFilePath,{ compression: "lz4" });yield OS.File.writeAtomic(nFilePath, jsonString);})}
if(FileName){
var oldFilePath = OS.Path.join(backupFolderPath, FileName+".jsonlz4");
var newFilePath = OS.Path.join(backupFolderPath, FileName+".json");
decompressBookmarksFile(oldFilePath,newFilePath);
console.log("Saved as: "+ newFilePath);
}
User avatar
jscher2000
Posts: 11762
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Reading "jsonlz4" bookmarkbackup files

Post by jscher2000 »

syryos wrote:I cannot get oen of the codes working in Firefox 40.0.3 console.
Message always is: TypeError: Cu is undefined . Please can anyone advice?

Hmm, that first one works for me in a quick try.

I wonder whether anything is required other than toggling devtools.chrome.enabled from false to true? My profile has a very long history of customization and I didn't test in a clean profile.
Post Reply