Skip to main content
  1. posts/

Automating My Obsidian Vault with Codex, Healthchecks, and Rsync

·5 mins

I’ve never been good at keeping my files neatly organized. My Obsidian _Inbox/ fills up, my root directory gets cluttered, and the good intentions of “I’ll sort it later” rarely turn into action. So I finally asked: why not get a computer to do it automatically for me?

That’s where Codex came in.


Wait, What’s Codex? #

Codex is primarily designed as a coding assistant—think of it as an AI that can help generate code, suggest fixes, and automate developer workflows. But it’s not just an API in the cloud. The Codex CLI is a command-line tool that runs directly on your computer. You can feed it a prompt and it acts like an agent: executing multi-step jobs locally, moving files, editing content, even committing to git.

That makes it powerful—and a little scary. It has a YOLO mode where it just does what you tell it with no confirmations. Running that against my notes felt like handing over the keys to my vault. I had to remind myself: yes, I really am letting an AI rummage through my Markdown files unsupervised.

And while it’s built to help with code, using it to reorganize an Obsidian vault of Markdown files feels like a novel hack.


The Organizing Principle #

The prompt I gave Codex wasn’t just “tidy things up.” It encoded the structure of my vault:

  • Triage first: _Inbox/ is where new notes land. The agent’s first job is to process and relocate them.
  • Folders by role:
    • Areas/ → ongoing responsibilities (Career, Family, Hobbies, etc.)
    • Projects/ → active initiatives with an end point
    • Resources/ → reference-only material (Reading, Reference)
    • Journal/ → chronological entries (daily notes, yearly folders)
    • Bookmarks/ → captured external content
  • Keep system files sacred: Attachments/, .obsidian/, thumbnails, and non-markdown files are never touched.
  • YAML + tags: Every note should have proper frontmatter with relevant tags.
  • Link integrity: Moves should never break [[WikiLinks]]. Codex searches for backlinks, updates links when it moves files, and even fixes broken ones if it’s confident.
  • Logging: Every action is written into automation/note-organizer-log.md, with exact “moved X from Y to Z” lines.

In other words, the rules I wish I followed manually—but now enforced automatically.


The Messy Middle #

Of course, it wasn’t smooth sailing. My first attempts were messy:

  • Running Codex over SSH left me staring at empty terminals, unsure if anything was happening.
  • Path confusion meant it couldn’t always find the vault when I wasn’t sitting in the right folder.
  • At one point, my script was half-broken because I’d pasted stray lines into my editor, leaving behind parse errors.
  • Codex also complained about sandbox restrictions in non-interactive mode, which meant some jobs aborted before they even touched a file.

It felt like every small fix uncovered a new failure.


The Breakthrough: Move It to the Pi #

Eventually I realized my Raspberry Pi—the same one already running Home Assistant, Pi-hole, and assorted background jobs—was the perfect host. It’s always on, and I don’t need to remote into it manually. So I copied my vault over and rebuilt the script:

  • Pointed it squarely at the Personal subfolder.
  • Added stdbuf so log output appeared line by line instead of in big delayed bursts.
  • Dropped in Healthchecks pings so I could track start, success, and failure.
  • Wired a Home Assistant webhook so I’d get a push notification when Codex was done.

For the first time, the logs ended with:

Codex finished OK.

And the vault actually showed changes. Huge relief.


The Sync Dance #

The Pi wasn’t where I usually edit notes. That’s still my Mac. So I needed to keep both in sync:

  1. Mac → Pi at 1:30 AM, so Codex always has the latest.
  2. Codex run at 2:00 AM on the Pi.
  3. Pi → Mac at 4:00 AM, sending the organized vault back.

Rsync made this straightforward. From the Mac side:

rsync -avz --delete   "/path/to/local/Obsidian/Personal/"   'user@pi-host:/path/to/pi/obsidian_cleaner/Personal/'   >> /path/to/local/obsidian_sync.log 2>&1 &&   curl -fsS https://hc-ping.com/71552884-f37a-44b2-8e8a-49fdaccd6f5d >> /path/to/local/obsidian_sync.log 2>&1

And on the Pi, cron handles the jobs:

0 2 * * * /path/to/pi/obsidian_cleaner/run_codex_obsidian_cleaner.sh start >> /path/to/pi/logs/codex/cron.log 2>&1
0 4 * * * rsync -az --delete /path/to/pi/obsidian_cleaner/Personal/ user@mac-host:/path/to/local/Obsidian/Personal/ >> /path/to/pi/logs/codex/rsync.log 2>&1

Leveraging Obsidian Sync #

My Mac is already syncing my vault through the Obsidian app. That means any changes Codex makes overnight get synced locally, and from there out to every one of my Obsidian clients—desktop, laptop, and mobile. I wake up and the tidy-up has already propagated everywhere.


Lessons Learned #

  • Don’t fight folder names with spaces. Renaming obsidian cleaner to obsidian_cleaner saved endless quoting issues.
  • Logs and pings make invisible processes visible. Healthchecks, log files, and push notifications gave me confidence it was running.
  • Build in layers. Test manually, then script it, then schedule it.
  • YOLO mode is both liberating and terrifying. Once you hand control over, you really need to trust the prompt.

What’s Next #

I’m thinking about adding git snapshots so I can see exactly what Codex changes night to night. And refining the prompts so the organization matches my tagging system better. For now though, it’s enough that I can trust the pipeline, and know my notes will be a little tidier by the time I pour my morning coffee.