Drive Sync
unlistedby Yuriy Bogomolov
Two-way sync of the vault with a Google Drive folder. Works on desktop and mobile.
Drive Sync for Obsidian
Drive Sync is an Obsidian plugin. It does a two-way sync of a vault with a folder in Google Drive. The same plugin runs on macOS and on Android. You do not need Google Drive for Desktop or a sync app on the phone.
How it works
- Each vault goes to the folder
My Drive/Obsidian Sync/<vault name>. The folder tree on Drive is the same as the tree of the vault. - The plugin uses the Drive API with the
drive.filescope. Thus the plugin sees only the files that it created. It cannot read other files in your Drive. - Each device keeps a record of the last sync. The plugin compares the local files, the Drive files, and this record. Then it uploads, downloads, or deletes only what changed.
- A sync starts when Obsidian opens, when the app comes back to the front, 20 seconds after the last edit, and every 5 minutes.
Conflicts
If you edit the same file on two devices between syncs, the plugin keeps both versions:
- The version from Drive keeps the original name.
- The local version gets a new name, for example
Note (conflict 2026-10-23 1405 Pixel).md.
Obsidian shows a notice with the names. Merge the two files by hand, then delete the conflict copy.
Deletes
- A delete on one device moves the file to the trash on the other side. Local files go to the
.trashfolder of the vault. Drive files go to the Drive trash. - If one device deletes a file and the other device edits it, the edit wins. The file comes back.
- If a sync wants to delete more than 25% of the files, it stops. This protects the vault if the Drive folder is missing. To continue, run the command Drive Sync: Force sync.
Files that never sync
.trash/,.git/,.DS_Storeworkspace*files in the config folder (the window layout of each device)plugins/drive-sync/data.json(the login and the sync record of each device)
You can add more patterns in the settings, for example Files/**/*.mp4.
Setup
1. Create a Google OAuth client (one time)
- Open https://console.cloud.google.com/ and create a project, for example "Obsidian Drive Sync".
- Go to APIs & Services > Library. Enable Google Drive API.
- Go to Google Auth Platform > Branding. Enter an app name and your email.
- Go to Audience. Select External.
- Go to Data access. Add the scope
https://www.googleapis.com/auth/drive.file. - Go to Audience again. Click Publish app.
- Go to Clients > Create client. Select the type TVs and Limited Input devices.
- Copy the client ID and the client secret.
Do step 6. If the app stays in "Testing", Google ends the login after 7 days. The drive.file scope is not sensitive, so Google does not review the app.
Put the values in the file client.json next to install.sh:
{ "clientId": "1234-abc.apps.googleusercontent.com", "clientSecret": "GOCSPX-..." }
You can also use the JSON file that Google Cloud Console downloads for the client. Rename it to client.json. The install script copies this file to each device. Then you do not type the values on the phone.
2. Build
npm install
npm test
npm run build
3. Mac
Keep the vault in a local folder, not in iCloud Drive or a Google Drive folder. Two sync tools on one folder cause duplicate files and conflicts.
-
Copy the vault out of iCloud. The iCloud copy stays as a backup:
rsync -a "$HOME/Library/Mobile Documents/iCloud~md~obsidian/Documents/Personal/" "$HOME/Obsidian/Personal/" -
Install the plugin:
./install.sh mac "$HOME/Obsidian/Personal" -
In Obsidian, select Open folder as vault and open
~/Obsidian/Personal. -
Go to Settings > Community plugins. Turn on community plugins, then enable Drive Sync.
-
Go to Settings > Drive Sync. Set Device name to
MacBook. Click Log in. -
Enter the code on the Google page and allow access. The first sync uploads the vault.
4. Pixel
-
In Obsidian on the phone, create an empty vault with the same name, for example
Personal. Put it in device storage, for exampleDocuments/Personal. -
Close Obsidian on the phone.
-
Connect the phone with USB and allow USB debugging. Install the plugin:
./install.sh android "/sdcard/Documents/Personal" -
Open Obsidian. Enable Drive Sync in Settings > Community plugins.
-
Go to Settings > Drive Sync. Set Device name to
Pixel. Click Log in and allow access. -
The first sync downloads the vault. Restart Obsidian once, so that it loads the synced settings and plugins.
If you do not use USB, copy the files main.js, manifest.json, styles.css, and client.json to Documents/Personal/.obsidian/plugins/drive-sync/ with a file manager.
More vaults
Do steps 3 and 4 for each vault, for example Ironsworn. Each vault has its own Drive folder and its own login.
Use
- Click the sync icon in the ribbon, or run Drive Sync: Sync now.
- On the Mac, the status bar shows the last sync time. Hover over it to see the counts or the errors.
Limits
- The plugin does not see files that you upload to the Drive folder with the Drive web page or the Drive app. Change files only through Obsidian.
- A rename is a delete and an upload. A rename of a large folder causes many uploads.
- Android does not accept these characters in file and folder names:
? : * " < > | \. The phone skips such files and shows their names. On the Mac, run the command Drive Sync: Fix file names for Android and Windows. It renames the files and updates the links to them. - macOS file names are not case-sensitive, Android file names are. Do not keep two files whose names differ only in case.
- Obsidian on Android runs the sync only while the app is open.
Troubleshooting
| Problem | Action |
|---|---|
| "Not logged in" or "Google revoked the login" | Click Log in in the settings again. |
| "Sync stopped: it would delete N files" | Look in My Drive/Obsidian Sync on the Drive web page. If the folder is correct, run Force sync. |
| A file fails each time | Hover over the status bar or open the developer console (Cmd+Option+I) for the error. |
| Sync is wrong after you changed the folder settings | Click Reset sync state. The next sync compares all files by content. It deletes no file. |
Development
src/planner.ts: decides the action for each file (pure function).src/engine.ts: runs the actions and handles conflicts and the delete guard.src/drive.ts: Google Drive client (folders, multipart and resumable upload, retries).src/auth.ts: OAuth device flow and token refresh.src/localfs.ts: vault access through the Obsidian API.src/main.ts: plugin, settings, triggers.
Run npm test for the unit tests. The tests use fake Drive and vault implementations.
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.