Obsidian sync from windows

Overview

This PowerShell-based automation sets up your Obsidian vault to sync with a private GitHub repo every 15 minutes.

  • Automatic commit + push of your notes
  • SSH key generation and registration
  • Runs entirely on Windows Task Scheduler


Getting Started

Prerequisites


Vault + GitHub Setup

Open PowerShell as an administrator in your Obsidian vault folder.

Generate SSH key

ssh-keygen -t ed25519 -C "YOUR_EMAIL@gmail.com"

When prompted: (I recommend using Vault path for smooth flow and not default key path)

Enter file in which to save the key: ➜ Type: D:\your_obsidian_vault\id_ed25519

Enable and start SSH agent

Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent

ssh-add D:\your_obsidian_vault\id_ed25519


you should see output like: “Identity added: path

Add key to GitHub

Get-Content D:\your_obsidian_vault\id_ed25519.pub

Copy the full key (output start from ssh-ed <SNIP> YOUR_EMAIL@gmail.com) → Go to GitHub → Settings → SSH and GPG Keys → New SSH Key → Paste and save.

Test the connection:

ssh -T git@github.com

prompt yes and you should see Hi @your_username! blah blah

Create private GitHub repo

  • Name it: obsidian-sync
  • ✅ Mark it private
  • ❌ Do not initialize with README or .gitignore

Initialize Git in your vault

git init
git remote add origin git@github.com:yourusername/obsidian-sync.git

Set-Content .gitignore ".obsidian/cache/`n.obsidian/workspace`n.obsidian/plugins`nid_ed25519`nid_ed25519.pub`nscripts/"
git add .
git commit -m "Clean initial commit: safe sync setup"
git branch -M main
git push -f origin main
·   ·   ·

Automation Script

Make new .ps1 file in the same directory and copy content from this one-time PowerShell script setup_obsidian_sync.ps1 and in same administartor pwershell.exe to automate syncing:

Set-ExecutionPolicy Bypass -Scope Process -Force
.\setup_obsidian_sync.ps1 -VaultPath "D:\your_obsidian_vault" -PrivateKeyPath "D:\your_obsidian_vault\id_ed25519"


This will:

  • Generate sync_obsidian.ps1 and load_ssh_key.ps1
  • Create two scheduled tasks:
    1. SSH key loader at login
    2. Auto-sync every 15 minutes (runs silently in the background)

·   ·   ·

Usage

Just update your notes in Obsidian - every 15 minutes the changes will be committed and pushed.

To test immediately:

Start-ScheduledTask -TaskName "Obsidian_Auto_Sync"

You can verify pushes by checking your GitHub repository.