Backup and restore Firefox bookmarks from command line?

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