Original link: http://catcoding.me/p/obsidian-andriod-client-sync-git/
I tried to configure the Obsidian client on Andriod last weekend, and I didn’t expect it to work quite well. If you have already purchased Obsidian’s sync service and everything is working fine, then you don’t need to read this introduction.
My main need for this is to use the Git repo of the private warehouse to synchronize the journal. Why not buy Obsidian sync
? I think Github is more in line with my usage habits, and one of the reasons I chose to use Obisidian is that I don’t want to synchronize note data to other third-party platforms. Relatively speaking, Github is the infrastructure I trust more. , after all, I have been using Github for so many years.
Android client
Obsidian’s Android client does not seem to be available in various domestic Android software markets. You need to use Google play to install it.
Termux
termux/termux-app is a terminal emulator for Android and is also an open source software. Basically, you can use Andriod as a simplified version of Linux server. The Termux advanced terminal installation, use and configuration tutorial is a very detailed introduction article.
Note that termux can no longer be installed on Google Play. You need to go to the apk installation package under Releases · termux/termux-app to install it manually.
After termux is installed, you can run a Shell on your Android phone, punch in and run to create a directory called storage
:
termux-setup-storage
Next install some dependencies that will be used later:
pkg install git pkg install openssl
Git
Use ssh-keygen
to generate a pair of public and private keys, configure the public key to your Github account, and then clone your Obsidian vault repo:
cd storage/share git config --global credential.helper store git config --global user.email "<your_email>" git config --global user.name "<The name you want on your commits>" git config --global pull.rebase true
Ensure that changes can be submitted correctly to Github on Termux. If there are some files that you do not want to synchronize to the remote, you can add them to .git/info/exclude
, for example, ignore .obsidian/workspace-mobile.json
.
Open the Obsidian client, find the directory where you just made the Git clone, and open it as a vault to use it.
Regular backup
First install the cron service on Termux:
pkg install cronie termux-services
Then exit Termux, reopen it, and run:
sv-enable crond
Run crontab -e
to create a scheduled backup job:
*/2 * * * * ~/sync_repo.sh
It automatically backs up every two minutes. My sync_repo.sh
looks like this:
#!/bin/bash cd /data/data/com.termux/files/home/storage/shared/ob git add -A && git commit -a -m "android backup: ` date + '%Y-%m-%d %H-%M-%S' ` " git pull git add . git rebase --continue git push
The above synchronization script is very rough. If there is a conflict, I will submit the conflict together, but this is also reasonable, because I need to make the automatic synchronization as successful as possible, and the conflict can be resolved on the laptop. If the Termux process is killed, automatic backup will not run automatically. But in my daily use, this isn’t a big issue.
refer to:
- Using Git to sync your Obsidian vault on Android devices – Share & showcase – Obsidian Forum
- Tutorial for automatically syncing an Obsidian vault with Git on an Android device
This article is reproduced from: http://catcoding.me/p/obsidian-andriod-client-sync-git/
This site is only for collection, and the copyright belongs to the original author.