vrtmrz / livesync-bridge

44 stars 6 forks source link

Recommendation: Support database/folder synchronization in different warehouses #2

Closed jiongxuan closed 10 months ago

jiongxuan commented 11 months ago

Hi, please ask vrtmrz:

I want to synchronize multiple Databases (Vaults) to multiple folders one by one for backup of original files without opening Obsidian. For example:

  1. DB_A --> Storage_A
  2. DB_B --> Storage_B ...

Judging from the code and documentation, LiveSync-Bridge currently supports the synchronization of a single warehouse (referring to the contents of the same folder). The main purpose is for sharing, but there is no "one-to-one" synchronization (used for backup and folders export) instance.

Please help to see if it is currently supported? And how to support? grateful!

Finally, a big thank you to contributors such as vrtmrz for making great Obsidian plug-ins, solving synchronization issues, and continuing to update them. Keep up the good work!

jiongxuan commented 11 months ago

Additional instructions:

The current solution that comes to mind is to open multiple livesync-bridge instances, and each instance establishes a different two-way synchronization. For example DB_A is:

{
   "peers": [
     {
       "type": "couchdb",
       "name": "A",
       "database": "db_a",
     },
     {
       "type": "storage",
       "name": "storage_a",
       "baseDir": "./storage_a/"
     }
   ]
}

And for DB_B it is:

{
   "peers": [
     {
       "type": "couchdb",
       "name": "B",
       "database": "db_b",
     },
     {
       "type": "storage",
       "name": "storage_b",
       "baseDir": "./storage_b/"
     }
   ]
}

Each time you use it, you need to open multiple Terminals or Dockers (for me), and bind a config to each Docker to achieve this capability in a roundabout way.

Currently I have 10+ DBs, so I need to open 10+ Docker containers (just for example. Docker has not been configured yet), which is obviously not a very suitable method. So we still need to look at this. Is there any better solution?

vrtmrz commented 11 months ago

I am so honoured to contribute to enriching and making our environment self-controllable with you!

Indeed we had to instantiate multiple LiveSync-Bridge. However, thanks to your insights, I have realised that it might be a good keyhole for the new features.

Now, we have a new property group in each peer configuration, and each change of peers will be dispatched only to the same group. At the moment, it simply uses complete matching, but we can add some functions here as our need. I felt very extensibility for this. It seems to have advantages over simply having many instances.

I have pushed the repo with these implementations. Would you mind if I ask you to check the behaviour, please?

jiongxuan commented 11 months ago

What a great method! By using Group, we not only achieve one-to-one (through group) requirements, but also provide good scalability for the future.

I expect to try this repo in the next two days. If I encounter any problems, I will communicate with you as soon as possible. Finally, thank you again for your quick response and active support!

jiongxuan commented 10 months ago

Sorry, I haven't had time to test it because I've been very busy recently. Considering that the problem has been solved, I closed the Issue first. Thanks again!

Judging from the code, there should be no problem (the principle is not complicated). If community members are interested, you can check out the code and experiment with it, and tell us the results in the message. Thank you!

When I'm done with this period of time, I'll take the time to experiment.