13

Is there an easy way to backup Firefox bookmarks to a file with command line. Running a find command, I managed to find this file: /.mozilla/firefox/9a5j5dbb.default/bookmarkbackups/bookmarks-2013-05-22.json which appears to have my latest data. However, I dont know if the folder under Firefox (currently 9a5j5dbb.default) will keep changing, and I'm pretty sure the date will.

Rather than a more advanced shell script to dynamically calculate the path based on today's date and looking for the only xxxxx.default folder under ~/.mozilla.

Is there a simpler/more-robust way to save/copy your current Firefox bookmarks to a specified file?

1
  • 1
    The folder named 9a5j5dbb.default is the Profile Folder of your Firefox. It won't change unless you re-install Firefox/Ubuntu. If you delete this folder, Firefox would create another randomly-generated-named folder for your Profile.
    – Aditya
    May 23, 2013 at 14:09

4 Answers 4

16

Using sqlite:

Firefox uses sqlite to store its data. Bookmarks are stored in ~/.mozilla/firefox/profile_name/places.sqlite. So we can use sqlite to backup and restore Firefox bookmarks.

Hit Ctrl+Alt+T to open terminal and run following command to install sqlite3:

apt-get install sqlite3

Now you can one following command to backup/restore Firefox bookmarks, make sure to close Firefox before running any of following commands.

Backup:

sqlite3 ~/.mozilla/firefox/user.profile/places.sqlite ".backup /path/to/directory"

Restore:

sqlite3 ~/.mozilla/firefox/user.profile/places.sqlite ".restore /path/to/backup/file"

Change user.profile with your default profile name.

Simple Backup:

If you don't want to install any additional packages use following command to copy latest bookmarks backup from Firefox profile:

cp $(find ~/.mozilla/firefox/fvy8ug06.default/bookmarkbackups | sort | tail -n1) .
4
  • Whilst this is probably the most 'proper' way to do things in the command shell, I still prefer Mr Seeds solution for 3 main reasons: 1) This rquired me to install sqlite3 2) This saved in a non-human readable format rather than the json format fo the other solution 3) This command was far less 'flexible' and I had to plug in an absolute path name for sqlite to work. Something like ~/data did not work. However, thank you for your input, and perhaps others will prefer to use this solution. May 24, 2013 at 12:00
  • @Programster - I suppose that, by "Mr Seeds" you mean Gaurav Sharma, because only him is the one who posted the JSON-related answer. I suppose also that he must have been changed his name/alias after your comment. Oct 20, 2016 at 19:09
  • +1 for the Simple Backup solution which includes "copy the latest json file".
    – wedi
    Nov 5, 2018 at 8:51
  • You can also just make a copy of ~/.mozilla/firefox/user.profile/places.sqlite, without using sqlite's .backup Nov 12, 2022 at 19:38
11

Well since there is only one .default in that folder you could use a wildcard like this:

*.default

sudo cp -fr /Path/to/Source/Folder/*.default /Path/to/Destination/Folder

2
  • This seems like the most appropriate answer so far because I can run it from the shell. I guess I just have to use this and pick the alphanumeric .json file to get the latest one. I was rather hoping I could run something like firefox --dump-bookmarks /my/folder/loc/bookmarks.json May 23, 2013 at 15:00
  • 1
    It's not necesary to use sudo as the profile folder is in $HOME. If sudo is used to make the copy, root will own the copied files, unless you of course used the -a switch with cp to preserve ownership.
    – user76204
    May 30, 2013 at 22:39
3
  • Working solution as of 30/10/2022

Set browser.bookmarks.autoExportHTML to true in about:config or user.js. This will generate a bookmarks.html file in your Firefox profiles' root directory eg. /home/snowman/.mozilla/firefox/0uffvdebh.default whenever the browser is closed.

See the Mozilla Support page for more information. Export all the bookmarks from a loads of profiles from a script

This file can be copied and imported as expected.

3
  • It doesn't generate any bookmarks.html here, only a bookmarkbackups folder, with .jsonlz4 files inside of it that i don't know how to open (7z seems not to be able to open them). Firefox 106.0.4. Nov 10, 2022 at 7:09
  • Hi @robertspierre. It does work for me. I have Mozilla Firefox 106.0.5 on Artix Linux. Note that the file is only generated when you close firefox.
    – rial
    Nov 12, 2022 at 13:06
  • Worked flawless - thanks @rial & also for the hint that its only generated after closing Firefox
    – ArgonQQ
    Feb 28, 2023 at 16:13
-3

In mozilla there is a option for taking the Backup of Bookmarks in JSON format.

You can follow these steps:-

  1. open all bookmarks (shift+ctrl+o)

  2. select 'Import and Backup' option (alt+i)

  3. Select 'Backup' option

here you can get all bookmark backup in json format.

1
  • 10
    -1 That's not from command line Jun 15, 2014 at 19:17

You must log in to answer this question.

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