Created
January 23, 2024 20:14
-
-
Save spoterianski/5fa41ecff926333f974647807156b20b to your computer and use it in GitHub Desktop.
backup obsidian on remote host using GIT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
HOST="remote-hostname" | |
PORT="22" | |
TIMEOUT="10" | |
OBSIDIAN_VAULT="/home/user/Obsidian/Notes" | |
if ssh -o ConnectTimeout=$TIMEOUT -p $PORT "$HOST" echo "SSH is up"; then | |
echo "Host $HOST is available" | |
else | |
echo "Host $HOST is not available. Exiting..." | |
exit 0 | |
fi | |
CURRENT_DIR=$(pwd) | |
# Sync Obsidian vault | |
echo "Syncing Obsidian vault..." | |
cd $OBSIDIAN_VAULT | |
git add -A | |
git commit -m "Backup $(date)" | |
git push origin master | |
echo "Obsidian vault synced" | |
cd $CURRENT_DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment