Obsidian to VPS Pipeline: Sync, Pull and Redeploy
One shell script on the Mac that pulls the site repository on the VPS, rsyncs the posts from the Obsidian vault and rebuilds the Astro container.
Reviewed by adrian
on
I wrote the posts for my old site in Obsidian. Publishing one meant opening VS Code, committing the Markdown, pushing, and then SSHing into the server to rebuild the container. Four steps in three places, and plenty of chances to forget one. I wanted a single command on my laptop to do all of it.
The setup
- Local: macOS, the Obsidian vault synced through iCloud Drive.
- VPS: Debian with
git, Podman andpodman-compose. - Site: Astro in a container managed by
podman-compose, the source at/opt/websites/www.adrian-altner.de.
The script does three things in order:
- Update the repository on the VPS (
git pull --ff-only). - Sync the Markdown posts from the Mac to the VPS (
rsync). - Rebuild and restart the Astro container (
podman-compose).
Paths
The vault lives inside iCloud's synced folder, so the local path has spaces and tildes and needs quoting every time:
/Users/adrian/Library/Mobile Documents/iCloud~md~obsidian/Documents/Web/adrian-altner-com/posts/
The target inside the Astro project:
/opt/websites/www.adrian-altner.de/src/content/posts
An SSH alias
An entry in ~/.ssh/config keeps the script readable, with ssh hetzner everywhere instead of an IP and flags:
Host hetzner
HostName <your-vps-ip-or-host>
User root
IdentityFile ~/.ssh/<your-key>
One seed post stays in Git
Most posts are written in Obsidian and synced, not committed. One seed file, hello-world.md, stays in Git, so a fresh clone still renders something. The .gitignore handles the split:
src/content/posts/*
!src/content/posts/hello-world.md
Commit the seed once:
git add src/content/posts/hello-world.md
git commit -m "add hello-world seed post"
git push
The publish script
~/bin/publish-posts.sh:
#!/usr/bin/env bash
set -euo pipefail
SRC='/Users/adrian/Library/Mobile Documents/iCloud~md~obsidian/Documents/Web/adrian-altner-com/posts/'
VPS="${1:-hetzner}"
REMOTE_BASE='/opt/websites/www.adrian-altner.de'
REMOTE_POSTS="${REMOTE_BASE}/src/content/posts"
# 1) Update code on VPS
ssh "$VPS" "cd '$REMOTE_BASE' && git pull --ff-only"
# 2) Sync posts from Obsidian to VPS
# The explicit exclude keeps a Git-tracked seed file safe from --delete.
ssh "$VPS" "mkdir -p '$REMOTE_POSTS'"
rsync -az --delete \
--exclude='hello-world.md' \
--include='*.md' --exclude='*' \
"$SRC" "$VPS:$REMOTE_POSTS/"
# 3) Rebuild and replace running container
ssh "$VPS" "cd '$REMOTE_BASE' && podman-compose -f compose.yml up --build -d --force-recreate"
echo "Repo pulled + posts synced + redeploy done via $VPS."
Two details carry the script:
--exclude='hello-world.md'keeps--deletefrom removing the seed post whenever it is not in the Obsidian folder.--include='*.md' --exclude='*'limits the sync to Markdown. Obsidian leaves.trashfolders and.obsidianconfig files next to the notes, and none of that belongs on the server.
chmod +x ~/bin/publish-posts.sh
~/bin/publish-posts.sh
Verify
Two SSH checks show that the container is up and not complaining:
ssh hetzner "podman ps --filter name=www.adrian-altner.de"
ssh hetzner "podman logs --tail 100 www.adrian-altner.de"
Then I open the new post in the browser: the route resolves, title and date render, no startup errors in the logs.
Troubleshooting
Container name conflict. podman-compose sometimes fails with name is already in use when an old container is stale. --force-recreate usually handles it. If not, remove the container by hand:
ssh hetzner "podman rm -f www.adrian-altner.de"
git pull blocked by local changes on the VPS. If someone edited files on the server, the fast-forward fails. Check with:
ssh hetzner "cd /opt/websites/www.adrian-altner.de && git status"
The fix is discipline, not tooling: keep the working tree on the VPS clean. Updating the Website Repository on a VPS has the same rule.
What came next
The posts linked each other with Obsidian wiki-links, which Astro does not understand. Obsidian Wiki-Links in Astro with a Remark Plugin resolves them at build time.
Takeaways
- Whitelist what rsync sends, or the editor's hidden files end up on the site.
- Every step of the script could later move to cron, launchd or CI without changing the interface.
Based on
-
Obsidian to VPS Pipeline: Sync, Pull, and Redeploy
(
raw/2026/2026-03-11/obsidian-to-vps-pipeline-sync-pull-and-redeploy.md) [post]
Topic
- Self-Hosting Running services on a server you control instead of using a provider's hosted version, with the upkeep that comes with it.
Uses
- Astro Tool for building websites from content such as Markdown. Ships plain HTML by default and only loads JavaScript where it is needed.
- Podman Container engine without a background daemon that runs rootless by default on Linux and uses the same commands on macOS and on a server.
Mentioned in
- My Old Astro Website My old site at adrian-altner.de: Astro with the Node adapter, typed content collections, IndieWeb features and photos as files with JSON sidecars.
Mentioned
- Updating the Website Repository on a VPS A repeatable update flow on the VPS: check the working tree, pull with --ff-only, rebuild with podman-compose, verify, roll back, all in one script.
See also
- Obsidian Wiki-Links in Astro with a Remark Plugin A small Remark plugin that turns Obsidian [[wiki-links]] into normal links at build time, with labels, heading anchors and a fallback for unknown targets.