Syncing browser bookmarks between browsers and machines in Linux

I use several computers and various browsers (predominantly Firefox, Chrome and Chromium) and was fed up with bookmarking a site on one machine and later not finding it on another machine. For quite some time I had therefore been looking for a simple way of synchronising browser bookmarks across all my machines and browsers, and I finally found one. Below I explain what I did.

I wanted to avoid storing my bookmarks on a third-party company’s server, so that ruled out tools such as Xmarks, EverSync, Google Bookmarks and the like. I wanted the bookmark database to reside on one of my own servers that is already accessible securely via the Internet. Apparently Xmarks optionally does enable you to use your own server providing you use only Firefox, but I use various browsers (Firefox is the default browser on my main laptop whereas Chrome is the default browser on my backup laptop, for example). Furthermore, I prefer to use open-source solutions whenever possible.

Although I was looking for a GUI solution, it turns out that the command-line bookmark manager Buku does a good job in a drop-down terminal such as Yakuake, Guake or Tilda. Buku is quite powerful, yet simple to use. It is certainly practical to use in a drop-down terminal (I’m currently using it with Yakuake in KDE, and with Tilda in LXDE). Not only can you click on links to open pages in the default browser, you can also easily configure your desktop environment to use a keyboard shortcut to bookmark directly from the browser window (see the instructions in the Buku Wiki for details).

Of course, if you only want to use Buku as a local bookmark manager on a machine, you can just install it and use it solely on that machine.

It is not difficult to set up a centralised Buku database that is then synchronised with any machine on which Buku is installed. If you do not have your own Cloud server (ownCloud or Nextcloud, for example), you could use Dropbox instead. The instructions are given in the Buku Wiki. Basically, I did the following to configure several machines to use Buku via the Cloud:

1. Use each browser’s bookmark manager to export the bookmarks to a file.

2. Install Buku on each machine (see ‘Installation‘ on the package’s GitHub repository page if your Linux distribution’s package manager does not offer Buku).

3. Launch Buku once on each machine to create the local database:

$ buku -p
DB file is being created at /home/fitzcarraldo/.local/share/buku/bookmarks.db.
You should encrypt it.
[ERROR] 0 records

4. On one machine, move the Buku database file (~/.local/share/buku/bookmarks.db) to a folder on the machine that is already being synced with the Cloud, then set up a symlink to it. For example:

fitzcarraldo@clevow230ss ~ $ ls -la ~/.local/share/buku/bookmarks.db
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 51 Mar 21 13:17 /home/fitzcarraldo/.local/share/buku/bookmarks.db -> /media/NTFS/Windows/ownCloud/Bookmarks/bookmarks.db

5. Allow the Cloud client on the other machines to download the bookmarks.db file into their local Cloud sync folder, then delete the local Buku database on each machine (~/.local/share/buku/bookmarks.db) and create a symlink to the Cloud-synchronised database file. For example, in addition to the symlink shown above on the machine clevow230ss, I have the following symlinks on two other machines:

fitzcarraldo@aspirexc600:~$ ls -la ~/.local/share/buku/bookmarks.db
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 42 Mar 21 16:05 /home/fitzcarraldo/.local/share/buku/bookmarks.db -> /home/fitzcarraldo/ownCloud/Bookmarks/bookmarks.db
fitzcarraldo@meshedgedx ~ $ ls -la /home/fitzcarraldo/.local/share/buku/bookmarks.db
lrwxrwxrwx 1 fitzcarraldo users 42 Mar 26 19:15 /home/fitzcarraldo/.local/share/buku/bookmarks.db -> /home/fitzcarraldo/ownCloud/Bookmarks/bookmarks.db

6. Use Buku on each machine to import the browser bookmark files that you created in Step 1. See the Buku documentation for the command. You can find documentation and a demo video on the above-mentioned GitHub page. The commands ‘man buku‘ and ‘buku --help‘ also list the commands. The man(ual) page also contains several examples to help you.

7. Use Buku as normal on each machine. You will be able to search the synchronised database, add bookmarks and edit them (title, URL, comment and tags), delete bookmarks, print bookmarks, click on links to view the pages in the default browser, and so on.

Looking through a flat list of bookmarks in a terminal window to find something is not as fast as in a GUI but, overall, Buku is a decent bookmark manager and its options are easy to learn and use. Buku’s comprehensive search options of course help to find bookmarks, but it is still not quite as ergonomic as a GUI bookmark manager in my opinion. The ability to have multiple tags in Buku does help, as you can search for either any or all tags. In a browser’s bookmark manager I would copy the same bookmark into different folders if the Web page covers multiple topics.

In summary, Buku is a viable bookmark manager and I like it. It is extremely easy to configure for use with a Cloud server, and I have set it up to synchronise bookmarks on all my machines. I have already imported into Buku the 1,300+ bookmarks from the various browsers on my machines, and deleted the bookmarks in those browsers, so I am using Buku in earnest. I just kept a few of the most-used bookmarks on the browser’s Bookmarks Toolbar, but I’m using Buku on my machines for all the other bookmarks.

If I do have to use a third-party machine running Windows or Linux without Buku installed, I would not be able to access my bookmarks from my Cloud server. To partially get around that, I created a cron job for my user account on each of my machines to periodically run Buku and print the bookmarks to a text file synced on my Cloud server. That way I can at least search through the text file remotely via the Cloud’s Web browser interface (or via WebDAV or via OpenVPN) if I cannot find the Web page I want in a search engine on the third-party machine.

fitzcarraldo@clevow230ss ~ $ crontab -l | grep -v \#
6,26,46 * * * * rm /media/NTFS/Windows/ownCloud/Bookmarks/*.txt; sleep 30s && /usr/bin/buku -p --nc > /media/NTFS/Windows/ownCloud/Bookmarks/Buku_bookmarks_backup.txt
fitzcarraldo@aspirexc600:~$ crontab -l | grep -v \#
1,21,41 * * * * rm /home/fitzcarraldo/ownCloud/Bookmarks/*.txt; sleep 30s && /usr/local/bin/buku -p --nc > /home/fitzcarraldo/ownCloud/Bookmarks/Buku_bookmarks_backup.txt
fitzcarraldo@meshedgedx ~ $ crontab -l | grep -v \#
11,31,51 * * * * rm /home/fitzcarraldo/ownCloud/Bookmarks/*.txt; sleep 30s && /usr/bin/buku -p --nc > /home/fitzcarraldo/ownCloud/Bookmarks/Buku_bookmarks_backup.txt

Below is a small taste of searching the bookmark database using Buku on any of my machines. Output is colour-coded (user-configurable), and links are clickable in a terminal window. You can search for any keyword(s), all keywords, sub-strings, just a tag or tags, regular expression matches, and so on. You can make titles immutable (read-only) if you want, or allow Buku to update them with the title from the Web site page. There is even a command that will check and list broken links. I will leave you to study the Buku documentation.

fitzcarraldo@aspirexc600:~$ buku -S Brazil samba
1. Kaká e Mário Monteiro são os novos carnavalescos da Imperatriz Leopoldinense [159]
   > http://www.sidneyrezende.com/editoria/carnaval
   +  Notícias sobre Carnaval 2016, escolas de samba, desfiles do Grupo Especial, Série A, ensaios técnicos, enredos, carnavalescos, bateria, mestre-sala, porta-bandeira, samba. Mangueira, Unidos da Tijuca, Vila Isabel, Beija-Flor, Grande Rio, Imperatriz, Mocidade, Portela, Salgueiro, União da Ilha, Viradouro, São Clemente, Porto da Pedra, Império da Tijuca, Império Serrano, Estácio de Sá, Caprichosos de Pilares, Tradição, Cubango, Em Cima da Hora, Inocentes de Belford Roxo, Alegria da Zona Sul, Unidos de Padre Miguel, Unidos de Bangu, Renascer de Jacarepaguá, Acadêmicos da Rocinha, Acadêmicos de Santa Cruz, Paraíso de Tuiuti, União de Jacarepaguá, União do Parque Curicica.
        
   # brazil,carnaval

2. Samba do Tuiuti 2018  Versão Acústica - YouTube [1270]
   > https://www.youtube.com/watch?v=yUxfwAzHOeY
   # brazil,carnaval,music,samba,video

buku (? for help) q

In this post I have only scratched the surface of what Buku can do. For example, a simple Buku command will encrypt (AES256) the bookmark database so you can prevent others viewing your bookmarks after you have finished searching the database, should you decide to store the database on a third-party Cloud server such as Dropbox. The search and editing tools are comprehensive yet straightforward, and you will quickly learn how to use them. I take my hat off to its developer, Arun Prakash Jana from Bangalore, India. He and the other contributors to Buku have done a great job, and I recommend you give Buku a try.

About Fitzcarraldo
A Linux user with an interest in all things technical.

5 Responses to Syncing browser bookmarks between browsers and machines in Linux

  1. Fitzcarraldo says:

    Nothing to do with Buku, but, just for information, the three machines mentioned in my post were using the cronie, cron, and vixie-cron daemons, respectively. However, I found that the file Buku_bookmarks_backup.txt on the machine running vixie-cron was always truncated. It appeared that somehow vixie-cron was not waiting for the Buku print command in the cron job to finish. So I stopped and disabled the vixie-cron daemon on that machine, uninstalled vixie-cron, installed cronie, enabled and started the cronie service, and everything now works fine. So I will avoid using vixie-cron in any future installations.

  2. francisco santos says:

    The struggle to sync bookmarks, passwords, etc etc… One of the things that still held me to Firefox was the convenient built-in “Sync” feature. But the performance difference to other browsers just became unbearable. Not only slow, but using more CPU resources and making my laptop overheat constantly. Finally switched to Chromium. Slowly transferring all my passwords to there manually, since there’s no “easy” automated way of doing it. At least the bookmarks could be imported.
    Then I stumble across another problem: I don’t have Linux installed on disk, I run it “live”, so every reboot (usually once a month) means that I have a fresh system again. And I have the chromium profile folder inside the “Live” environment’s RAMdisk, to not cause excessive wear to an already old disk. Set up a chromium “backup and compress” script set to a keyboard shortcut, run manually, works great. The whole thing gets compressed down to 2MB.
    Now for the “problem” part: every once in a while, I go through system freezes (98% of the time overcommit-freezes… honestly I imagined Linux was smarter than this, being that it is seen as a “server” OS…) and then I lose some of the most recent chromium bookmarks and the tabs I had open, cookies that I had set up, etc. So what I’ve figured was manually creating a symlink to the Bookmarks file, so the most important stuff is always on disk. Keep the Bookmarks file on another partition on disk, and have the chromium profile folder have a symlink pointing to it inside, so it’s permanently written on disk.
    Then I notice the symlink gets replace by a new Bookmarks file. Never seen a symlink being replaced ever. Turns out the Bookmarks file inside the chromium profile directory gets recreated from scratch every time I add a new bookmark. (I always imagined Chromium would “append” information to the file, not re-writing it all from zero… another concern regarding disk wear, if you want to keep it to a minimum…) So I’m currently looking for how could I overcome this. Maybe the only solution will be a periodic cron job to manually “copy and replace” the Bookmark file a few times a day. Any ideas, shout it out!

    • Fitzcarraldo says:

      You say that you’re using a Live environment. If you use a Live USB pendrive, you can use a Live Linux distribution such as Porteus which can easily be configured to be persistent and would therefore maintain all the browser’s bookmarks between reboots/shutdowns. I configure Porteus Linux on my USB pendrives to use the so-called ‘changes cheatcode’, and Porteus saves any and all changes I make in the Live environment, including all bookmarks saved in the Web browser (Firefox, Chrome, Chromium, Palemoon or Opera, whichever one you use). Try that. I’ll probably be posting in future about how I install Porteus on a USB pendrive and configure it for persistent use, but you should be able to work it out from the documentation on the Porteus Linux Web site (a search engine will find it). It’s a very fast and compact portable Linux distribution, and has all the main Desktop Environments. I have settled on Porteus Xfce, although all the Porteus DEs are reasonable. My USB pendrives with Porteus can boot fine on PC BIOS machines and UEFI machines.

    • Fitzcarraldo says:

      By the way, as you’re Brazilian, I think brokenman, one of the Porteus Linux developers and an administrator of the Porteus Linux Forums, is Brazilian. (Bem, pelo menos a assinatura dele no fórum de Porteus Linux indica que ele mora no Brasil).

  3. Pingback: Moving from Lubuntu 18.04 to 20.10 | Fitzcarraldo's Blog

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.