How to backup and restore Firefox bookmarks from command line?
Solution 1
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
Solution 2
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) .
Related videos on Youtube
Programster
Updated on September 18, 2022Comments
-
Programster over 1 year
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?
-
Admin almost 11 yearsThe 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.
-
-
Programster almost 11 yearsThis 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
-
Programster almost 11 yearsWhilst 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.
-
secure almost 11 yearsIt'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.
-
Babken Vardanyan almost 10 years-1 That's not from command line
-
Cristiana Nicolae over 7 years@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.
-
wedi over 5 years+1 for the Simple Backup solution which includes "copy the latest json file".