Skip to content

Instantly share code, notes, and snippets.

@spoterianski
Created January 23, 2024 20:14
Show Gist options
  • Save spoterianski/5fa41ecff926333f974647807156b20b to your computer and use it in GitHub Desktop.
Save spoterianski/5fa41ecff926333f974647807156b20b to your computer and use it in GitHub Desktop.
backup obsidian on remote host using GIT
#!/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