ObsidianEncryptedCloudSync
These are scripts to encrypt Obsidian vaults at rest and to sync them over the cloud.
A setup and shell scripts to use a public cloud service as Dropbox to sync encrypted Obsidian Vaults between Mac an/or Linux and/or Android devices. No root needed.
When closing the vault, the script will create an encrypted 7z archive of the vault and upload it to the cloud. After closing, all unencrypted notes are deleted.
To retrieve your notes, the script will make an unzipped copy of the archive available locally.
Installation
Mac / Linux:
- Create a cloud linked folder (such as ~/Dropbox/Obsidian_Cloud)
- Create a local folder that is not linked to the cloud (such as ~/Obsidian_Local)
- Place your vault to be encrypted and synced in Obsidian_Local
- Rename vault to private_notes
- Optional if you want to sync Obsidian settings across devices:
- Open private_notes in Obsidian
- create a symbolic link to local folder
ln -s ~/Dropbox/Obsidian_Cloud/.obsidian ~/Obsidian_Local/
- Install 7-zip
- Zip and encrypt your private_notes using Terminal
7z a -mhe -t7z private_notes.7z private_notes(You will be prompted for a password. Note it down!) - dowonload toggle_private.sh from repository and place it anywhere on your computer
- Edit script to adapt to your local and cloud paths in the heading
- Make script executable
chmod +x toggle_private.sh - Optional in Mac: Make skript a command as to execute it on click
mv toggle_private.sh toggle_private_vault.command
Android:
- Install Termux and Termux Widget
- Install Cloud Service App (as Dropbox) of your choice
- Install a Folder Sync App of your choice (as Dropsync)
- In File Manager, create a Obsidian_Local folder anywhere on your device
- In the Folder Sync App, pair Obsidian_Local with Obsidian_Cloud.
- In the Folder Sync App settings, exclude pattern private_notes to be synched.
- Download toggle_droid.sh from repository to your device
- Edit script to adapt to path to your Obsidian_Local folder
- Open Termux and move script:
mkdir .shortcuts; mv /path_to/toggle_droid.sh .shortcuts - Make script executable
chmod +x .shortcuts/toggle_droid.sh - Type
7zand install the package as instructed. Should you recieve a package unavailable error message change mirror:termux-change-repo - On your Android launcher, start Termux Widget and make a widget pointing to toggle_droid.sh
Usage
(on any device)
- Start toggle_private or toggle_droid respectively through click or via command line
- If vault is open, you will be promted to close it
- If vault is closed, you will be prompted for password to open it
File Creation Dates
Zipping and unzipping may distort the order of note creation shown when displaying a list in Obsidian's file explorer. To account for this, the scripts include a loop to reset file creation dates to dates set in note yaml metadata. To make use of this, set a template to begin your notes with this heading:
---
created: YYYY-MM-DD HH:MM
e.g.
---
created: 2022-01-20 17:01
If you do not care about file creation order, simply remove the loop from the scripts.