1
0
mirror of https://github.com/vrtmrz/obsidian-livesync.git synced 2024-12-12 09:04:06 +02:00
Go to file
vorotamoroz 6fcb6e5a6a bumped
2021-11-15 12:25:45 +09:00
images Add readme. 2021-10-27 18:28:30 +09:00
instruction_images brushup readme 2021-10-13 21:38:44 +09:00
pouchdb-browser-webpack rewrited file treatment 2021-10-14 19:27:08 +09:00
.gitignore fixed some base on awsome advices. 2021-10-17 11:06:25 +09:00
LICENSE documentation improvement 2021-10-15 01:27:24 +09:00
main.ts Fix 3 issues, implement a feature, and tidy up . 2021-11-15 12:25:18 +09:00
manifest.json Fix 3 issues, implement a feature, and tidy up . 2021-11-15 12:25:18 +09:00
package-lock.json bumped 2021-11-15 12:25:45 +09:00
package.json Fix 3 issues, implement a feature, and tidy up . 2021-11-15 12:25:18 +09:00
pouchdb-browser.js initial commit 2021-10-12 23:50:13 +09:00
README.md Improved: 2021-11-09 15:05:12 +09:00
rollup.config.js first replication error fixed and minor some fixed 2021-10-15 12:30:06 +09:00
styles.css fixes below: 2021-11-08 17:52:07 +09:00
tsconfig.json brushup readme 2021-10-13 21:38:44 +09:00
versions.json initial commit 2021-10-12 23:50:13 +09:00

Self-hosted LiveSync

Renamed from: obsidian-livesync

This is the obsidian plugin that enables livesync between multi-devices with self-hosted database.
Runs in Mac, Android, Windows, and iOS.
Community implementation, not compatible with official "Sync".

obsidian_live_sync_demo

It's getting almost stable now, But Please make sure to back your vault up!

Limitations: Folder deletion handling is not completed. It would work now.

This plugin enables..

  • Live Sync
  • Self-Hosted data synchronization with conflict detection and resolving in Obsidian.
  • Off-line sync is also available.
  • Receive WebClip from obsidian-livesync-webclip

IMPORTANT NOTICE

Please make sure to disable other synchronize solutions to avoid content corruption or duplication. If you want to synchronize to both backend, sync one by one, please.

How to use

  1. Install from Obsidian, or clone this repo and run npm run build ,copy main.js, styles.css and manifest.json into [your-vault]/.obsidian/plugins/ (PC, Mac and Android will work)
  2. Enable Self-hosted LiveSync in the settings dialog.
  3. If you use your self-hosted CouchDB, set your server's info.
  4. or Use IBM Cloudant, take an account and enable Cloudant in Catalog
    Note please choose "IAM and legacy credentials" for the Authentication method Setup details are in Couldant Setup Section.
  5. Setup LiveSync or SyncOnSave or SyncOnStart as you like.

Test Server

Setting up an instance of Cloudant or local CouchDB is a little complicated, so I made the Tasting server of self-hosted-livesync up. Try free!
Note: Please read "Limitations" carefully. Do not send your private vault.

WebClipper is also available.

Available from on Chrome Web Store:obsidian-livesync-webclip
Repo is here: obsidian-livesync-webclip. (Docs are work in progress.)

When your database looks corrupted or too heavy to replicate to a new device.

self-hosted-livesync changes data treatment of markdown files since 0.1.0
When you are troubled with synchronization, Please reset local and remote databases.
Note: Without synchronization, your files won't be deleted.

  1. Update plugin on all devices.
  2. Disable any synchronizations on all devices.
  3. From the most reliable device(The device), back your vault up.
  4. Press "Drop History"-> "Execute" button from The device.
  5. Wait for a while, so self-hosted-livesync will say "completed."
  6. In other devices, replication will be canceled automatically. Click "Reset local database" and click "I'm ready, mark this device 'resolved'" on all devices.
    If it doesn't be shown. replicate once.
  7. It's all done. But if you are sure to resolve all devices and the warning is noisy, click "I'm ready, unlock the database". it unlocks the database completely.

Designed architecture

How does this plugin synchronize.

Synchronization

  1. When notes are created or modified, Obsidian raises some events. obsidian-live-sync catch these events and reflect changes into Local PouchDB.
  2. PouchDB automatically or manually replicates changes to remote CouchDB.
  3. Another device is watching remote CouchDB's changes, so retrieve new changes.
  4. obsidian-live-sync reflects replicated changeset into Obsidian's vault.

Note: The figure is drawn as single-directional, between two devices. But everything occurs bi-directionally between many devices at once in real.

Techniques to keep bandwidth low.

dedupe

Cloudant Setup

Creating an Instance

  1. Hit the "Create Resource" button. step 1

  2. In IBM Cloud Catalog, search "Cloudant". step 2

  3. You can choose "Lite plan" for free. step 3

Select Multitenant(it's the default) and the region as you like. step 4 3. Be sure to select "IAM and Legacy credentials" for "Authentication Method". step 5

  1. Select Lite and be sure to check the capacity. step 6

  2. And hit "Create" on the right panel. step 7

  3. When all of the above steps have been done, Open "Resource list" on the left pane. you can see the Cloudant instance in the "Service and software". Click it. step 8

  4. In resource details, there's information to connect from self-hosted-livesync. Copy the "External Endpoint(preferred)" address. (*1). We use this address later, with the database name. step 9

CouchDB setup

  1. Hit the "Launch Dashboard" button, Cloudant dashboard will be shown. Yes, it's almost CouchDB's fauxton.
    step 1

  2. First, you have to enable the CORS option. Hit the Account menu and open the "CORS" tab. Initially, "Origin Domains" is set to "Restrict to specific domains"., so set to "All domains(*)"
    NOTE: of course We want to set "app://obsidian.md" but it's not acceptable on Cloudant. step 2

  3. And open the "Databases" tab and hit the "Create Database" button.
    Enter the name as you like (*2) and Hit the "Create" button below.
    step 3

  4. If the database was shown with joyful messages, setup is almost done. And, once you have confirmed that you can create a database, usullay there is no need to open this screen. You can create a database from Self-hosted LiveSync. step 4

Credentials Setup

  1. Back into IBM Cloud, Open the "Service credentials". You'll get an empty list, hit the "New credential" button. step 1

  2. The dialog to create a credential will be shown. type any name or leave it default, hit the "Add" button.
    step 2
    NOTE: This "name" is not related to your username that uses in Self-hosted LiveSync.

  3. Back to "Service credentials", the new credential should be created.
    open details.
    step 3
    The username and password pair is inside this JSON.
    "username" and "password" are so.
    follow the figure, it's "apikey-v2-2unu15184f7o8emr90xlqgkm2ncwhbltml6tgnjl9sd5"(*3) and "c2c11651d75497fa3d3c486e4c8bdf27"(*4)

Self-hosted LiveSync setting

xx example values.

Items Value example
CouchDB Remote URI: (*1)/(*2) or any favorite name https://xxxxxxxxxxxxxxxxx-bluemix.cloudantnosqldb.appdomain.cloud/sync-test
CouchDB Username (*3) apikey-v2-2unu15184f7o8emr90xlqgkm2ncwhbltml6tgnjl9sd5
CouchDB Password (*4) c2c11651d75497fa3d3c486e4c8bdf27

License

The source code is licensed MIT.