I have a Raspberry Pi running a headless calibre (0.8.51) and a MacBook running also calibre. My idea is to keep the two libraries in sync so if I add a book on one computer I will also be able to access it from the second.

Now, I am trying to define a strategy to avoid troubles.

I know that if I try to sync one library while the very same library is also being used by calibre I can corrupt the database. But then, calibre on the raspberry is always on (I use it to download recipes). If I make sure that calibre on the raspberry is adding books only when no sync is going on (that is, calibre is running but not accessing the library), do I still risk to corrupt the database? Should I then make sure that when I sync both calibre are off?

Also, the fact that calibre on the Raspberry is a much older version than calibre on the mac could create compatibility issue while accessing the same library?

One trick is to use a "buffer copy" of the library. Then you don't have to turn calibre off on both the laptop and the Pi. Instead you write changes to the buffer copy, and on restart sync with that buffer copy. The buffer should be on a network share that is always available for both the laptop and the Pi.

Also you have to decide the direction of the changes. Typically I assume that you add news on the Pi, and add books and update metadata on the laptop?

This can be managed by having two calibre libraries and two buffer copies. One for news, Pi->buffer1->Laptop, and one for actual books, Laptop->buffer2->Pi.

You can sync to buffer automatically when you shut down calibre by adding steps to the script that launch calibre, after calibre has been run in the script. You can sync from the buffer by adding steps to the script before calibre is run.

One trick is to use a "buffer copy" of the library. Then you don't have to turn calibre off on both the laptop and the Pi. Instead you write changes to the buffer copy, and on restart sync with that buffer copy. The buffer should be on a network share that is always available for both the laptop and the Pi.

Also you have to decide the direction of the changes. Typically I assume that you add news on the Pi, and add books and update metadata on the laptop?

This can be managed by having two calibre libraries and two buffer copies. One for news, Pi->buffer1->Laptop, and one for actual books, Laptop->buffer2->Pi.

You can sync to buffer automatically when you shut down calibre by adding steps to the script that launch calibre, after calibre has been run in the script. You can sync from the buffer by adding steps to the script before calibre is run.

That's interesting. Have you direct experience with it? Do you think this will create less conflicts than sync directly the two libraries? One problem I see in this is that at the end of the day you mantain 4 libraries instead of 2.

As I see it you still only maintain your original library/libraries, exactly as usual, but now you also have a backup copy.

I use this procedure, an intermediary copy, to send books to my device and to make backups of the entire calibre library.

I have a folder on my NAS that is a copy of the book folders on my device. I connect to this folder from Calibre and send updates and changes there.

My device automatically sync from this folder using the app FolderSync every hour, but only if charging, or if manually launched.

Also when I quit calibre a backup copy of the calibre library is automatically updated using rsync. This backup copy is then daily backuped using "Time Vault" style backup to external USB harddrive. The backup is also used to automatically refresh the library used by a VM, every time the VM is started. I sometimes use the VM to run the calibre content server.

I use the intermediary buffer to avoid having to turn things on and off at both ends, before I can send/backup.

I only have one "main" instance of calibre, that is where I add books and update metadata and so on. I don't fetch news.