Corrupted collection.anki2 — backups/export invalid, SQLite recovery incomplete

Hi, I’m trying to recover a corrupted Anki collection on macOS and I’m hoping there may still be a way to salvage my recent cards/review history.

I had been seeing the message table had usn=-1: revlog for roughly at least over a week (I’m not sure exactly how long), but Anki continued to open normally and my cards/edits were still present. Every time I exited out of Anki, it would say the file is corrupt and I’ve attached the picture below. I kept ignoring it but now I think I need to do something about it.

I also then tried to sync and received an error saying my upload was corrupt and to run Check Database.

Running Tools → Check Database gave:

Collection file is corrupt. Please restore from an automatic backup.

My current collection still opens and shows my decks, including recent edits to AnKing cards and recent study progress, but attempts to export now fail with:

DatabaseCorrupt ... database disk image is malformed

I stopped trying to sync it, and I made a full copy of the profile before attempting repairs. But I’m afraid maybe the copies I made are also corrupt too. I don’t remember how long it’s been corrupt for.

Things I have already tried:

  • Updated Anki from 25.09.4 to 26.09
  • Made a full copy of the User 1 profile before repair attempts
  • Manual .colpkg export — Anki reports it is not a valid package when imported
  • Automatic .colpkg backups — multiple backups also report as invalid
  • sqlite3 collection.anki2 .dump > dump.txt
    • dump ended with ROLLBACK; -- due to errors
    • changing this to COMMIT; and rebuilding produced many errors, including missing sqlite_stat4, fields, templates, notetypes, and decks
  • SQLite .recover:
    • sqlite3 collection.anki2 ".recover" > recovered.sql
    • rebuilt into a new database successfully at the SQLite level
    • when Anki opened it, it failed with no such table: decks
  • Tried exporting a single deck as .apkg with scheduling information, but export failed with:
    • DatabaseCorrupt ... database disk image is malformed
  • My iPhone copy is older and does not contain my recent work

The current corrupted Mac collection is still readable enough that I can browse my decks and see recent edits/cards, but Anki cannot export or validate it.

Is there any Anki-specific recovery method that could salvage:

  • recent note/card edits,
  • recent review history/scheduling,
  • or rows from the corrupted collection.anki2

without reverting fully to an older copy?

I can provide the raw collection.anki2 file if needed. It is about 125 MB.

I’d appreciate any guidance on whether this collection is still recoverable and what files would be most useful. Thanks!

Some ideas about how to recover –

I can see your attempts to repair the database, but it’s not clear if you followed through with the rest of the directions in the manual – Managing Files - Anki Manual – or if you were following some other guide that was incomplete. Please go through all the steps.

The other main way to recover is those other version of your collection, so how much older are they? You said you’ve been getting errors for at least a week, but it looks like you’ve synced both desktop and AnkiMobile with the server today or yesterday.

If your iphone is only a day out-of-date, that’s definitely a better place to start than a completely corrupted database. You can check that version of your collection by creating a new profile in desktop Anki.

  • If AnkiWeb is the most updated version, other than desktop [meaning you’ve synced some things from desktop, but AnkiMobile doesn’t yet have them] – set up syncing in that new profile on desktop and download from AnkiWeb.
  • If AnkiMobile is the most updated version, force a one-way sync from there – ⚙️ Preferences > Syncing > One-Way Sync and then when you sync, choose upload to AnkiWeb. Then you can proceed with the above and set up syncing.

I don’t know if the most recent changes you’re worried about are review history or edits/updates/additions. If they are edits/updates/additions – have you tried exporting the notes as “Notes in Plain Text”? If that works, and you can get a day-old version of your collection from your other device working, you should be able to import that plain text/CSV file and update your existing notes.

If you’ve been getting the errors for at least a week, you might need to go back to a backup before that. Can you remember the first time you saw the errors?