I use Obsidian git on PC, and this workaround (since the plugin doesn't support mobile) to seamlessly* sync my notes to and from my phone. Using these instructions you create an automation for pulling every time you open Obsidian, and pushing every time you close it.
* you can still get merge conflicts...
- Install Tasker.
- Install Termux.
- Install Termux tasker plugin.
- Open Termux and write
termux-setup-storage
, give it permissions. - Generate a new ssh key and add it to your Github profile.
pkg install git
.cd ~/storage/shared
and clone / create a repository in a folder of your choice. I use~/storage/shared/Repos/Obsidian
.mkdir ~/.termux/tasker/
andcd ~/.termux/tasker/
.chmod 700 -R /data/data/com.termux/files/home/.termux
- Create the scripts below inside the folder from step 7.
You need two scripts
pull.sh
andbackup.sh
. I added another script -reset.sh
, which I use for resetting in case of merge conflict. - Give tasker permission to "run both user-defined and its own tasks" and "run commands in Termux environment".
#!/data/data/com.termux/files/usr/bin/bash
git pull
exit 0
#!/data/data/com.termux/files/usr/bin/bash
git add .
git commit -m "mobile backup"
git push
exit 0
#!/data/data/com.termux/files/usr/bin/bash
git reset --hard
exit 0
Create a task for every script: Tasker > tasks > create
If you want your tasks to ask you for permission and / or print output messages, then configure your tasks like this (see the example below):
1. "pick input dialog" action of type YesOrNo with title "pull?" / "push?" / "reset?".
2. "If" action, If: %input ~ yes
3. Termux action (the ones defined below)
4. "If" action, If: %stdout NEQ \%stdout
5. "Flash" action, Text: %stdout
6. End if
7. "If" action, If: %stderr NEQ \%stderr
8. Flash action, Text: %stderr
9. End if
10. End if
- path:
script.sh
(i.e.backup.sh
,pull.sh
orreset.sh
).
- arguments:
- None
- working directory path:
~/storage/shared/Repos/Obsidian
(or whatever you use).
- execute in a terminal session:
- unchecked
When you have your tasks ready you can create your Tasker profile (see the example below):
- Choose application -> Obsidian.
- Choose your pull task.
- Long press the green arrow next to your pull task, and choose "add exit task".
- Choose your backup task.
Hi, Thanks for the guide! Where can I create a profile?