anki-snapshot: Git-Based Version Control for Your Anki Collection

I’ve released anki-snapshot, a tool that brings proper version control to your Anki flashcard collection. Every change to your notes is tracked in git, giving you full history, searchable diffs, and the ability to see exactly what changed and when.

The Problem

Anki’s built-in backup system saves complete snapshots of your database, but it doesn’t tell you what changed. If you accidentally delete a note, modify a card incorrectly, or want to see how your deck evolved over time, you’re stuck comparing opaque database files.

The Solution

anki-snapshot exports your Anki collection to human-readable text files and commits them to a git repository. This means you get:

  • Full history: See every change ever made to your collection
  • Meaningful diffs: View exactly which notes were added, modified, or deleted
  • Search through time: Find when a specific term appeared or disappeared
  • Easy recovery: Restore individual notes from any point in history

How It Works

The tool reads your Anki SQLite database and exports notes and cards to pipe-delimited text files. These files are tracked in git, so each time you run anki-snapshot, any changes are committed with a timestamp.

~/anki-snapshot/
├── .git/
├── notes.txt      # All notes: id|model|fields...
├── cards.txt      # All cards: id|note_id|deck|type|queue|due|ivl...
└── decks.txt      # Deck information

Commands

CommandDescription
anki-snapshotExport current state and commit to git
anki-diffShow changes since last snapshot
anki-logShow commit history with stats
anki-search "term"Search current notes for a term
anki-search "term" --historySearch through all git history
anki-restore <commit> <note_id>Restore a specific note from history

Example: Tracking Changes

After editing some cards in Anki, run the snapshot and see what changed:

$ anki-snapshot
[main a3f2b1c] Snapshot 2026-01-14 21:30:45
 1 file changed, 3 insertions(+), 1 deletion(-)

$ anki-diff
━━━ Changes since last snapshot ━━━

Modified notes: 2
+ [1462223862805] Which antibodies are associated with Hashimoto...
− [1462223862805] Which antibodies are associated with Hashimoto...

New notes: 1
+ [1767170915030] Germline polymorphisms of the ATPase 6 gene...

Example: Searching History

Find when “mitochondria” was added or modified across your entire collection history:

$ anki-search "mitochondria" --history

commit e183cea7b3e36ad8b8faf7ca9d5eb8ca44d5bb5e
Date:   Tue Jan 13 22:43:47 2026 +0100
+ [1469146863262] If a disease has a mitochondrial inheritance pattern...
+ [1469146878242] Mitochondrial diseases often demonstrate variable expression...

commit 41c25a53471fc72a520d2683bd3defd6c0d92a88
Date:   Tue Jan 13 22:34:48 2026 +0100
− [1469146863262] If a disease has a mitochondrial inheritance pattern...

Integration with Anki

For seamless integration, you can hook the snapshot into your Anki workflow. I use a wrapper script that runs the snapshot automatically when closing Anki:

$ anki-wrapper  # Opens Anki, snapshots on close

Or add it to your shell aliases to run before building/syncing your deck.

Installation

The tool is available on the AUR for Arch Linux users:

yay -S anki-snapshot

Or install manually:

git clone https://github.com/chrislongros/anki-snapshot-tool
cd anki-snapshot-tool
./install.sh

Requires: bash, git, sqlite3

Why Not Just Use Anki’s Backups?

Anki’s backups are great for disaster recovery, but they’re binary blobs. You can’t:

  • See what changed between two backups without restoring them
  • Search for when specific content was added
  • Selectively restore individual notes
  • Track your collection’s evolution over months or years

With git-based snapshots, your entire editing history becomes searchable, diffable, and recoverable.

Source Code

github.com/chrislongros/anki-snapshot-tool


Leave a comment

Discover more from /root

Subscribe now to keep reading and get access to the full archive.

Continue reading