MozillaZine

Reading "jsonlz4" bookmarkbackup files

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

Post Posted January 26th, 2015, 5:44 pm

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!

therube

User avatar
 
Posts: 20061
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted January 26th, 2015, 7:50 pm

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/
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

Post Posted April 9th, 2015, 10:07 am

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

Post Posted April 9th, 2015, 10:13 am

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

Post Posted April 9th, 2015, 10:17 am

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 :)

dickvl

User avatar
 
Posts: 52840
Joined: July 18th, 2005, 3:25 am

Post Posted April 9th, 2015, 5:11 pm

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);
}
Last edited by dickvl on August 30th, 2015, 5:26 pm, edited 1 time in total.

therube

User avatar
 
Posts: 20061
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted April 9th, 2015, 5:55 pm

@pijani, are you really running FF 19?
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: 281
Joined: October 16th, 2004, 6:23 pm

Post Posted June 9th, 2015, 3:49 pm

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: 281
Joined: October 16th, 2004, 6:23 pm

Post Posted June 9th, 2015, 3:50 pm

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: 749
Joined: December 30th, 2009, 11:25 pm

Post Posted June 9th, 2015, 4:13 pm

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

Post Posted September 8th, 2015, 11:26 am

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.

therube

User avatar
 
Posts: 20061
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted September 8th, 2015, 7:33 pm

(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.)
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

Post Posted September 8th, 2015, 9:00 pm

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

Post Posted September 22nd, 2015, 1:55 pm

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);
}

jscher2000

User avatar
 
Posts: 10743
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted September 22nd, 2015, 4:49 pm

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.

Return to Firefox Support


Who is online

Users browsing this forum: No registered users and 6 guests