Anki Decks data recovery

At one point I was really jazzed about creating my own Anki decks to try to help me memorize things. I really like the platform and the no-frills aesthetics.

Recently I wanted to get back into it except I had two compounding problems:

  1. My AnkiWeb account data was deleted due to inactivity
  2. The Anki data on my Android device is inaccessible by the app due to the fact that the device revoked the app's storage access permissions at one point in the past

I made a backup of my data on the device and then uninstalled the app but wasn't able to find a way to re-import it after re-installing. So I was stuck, but not for long.

The rest of this post documents an alternative recovery workflow. I don't know if I recommend this since it was honestly a lot of work. However, I wasn't willing to let go.

revive the AnkiWeb account

My account still exists on AnkiWeb.net, but the data has been deleted. To their credit they did give me exactly 1 warning ( which I ignored ) and then they no longer emailed me. True to their word.

download the desktop app

The linux version for me, which of course comes with its own set of installation instructions. A few minutes on the command line and ...

Install complete. Type 'anki' to run.
Let my people import

Installing the desktop app and syncing it with AnkiWeb will give an interface for importing the data, which AnkiWeb does not provide.

get the data off the phone

I don't actually have exports in the format they recommend (.apkg), I just have a bunch of random files off the phone storage. Ever heard of a .colpkg file? Neither have I.

At this point I realize all the assets ( images ) are separate files and my confidence in this process starts to wane. I upload everything to a folder on my Google Drive storage.

import the data into Anki desktop?

At this point I haven't synced the desktop app with AnkiWeb yet because I don't want it syncing anything until I'm sure that everything is ... correct

I downloaded the backup files from Google Drive to my laptop.

I used the 'Import File' button to point to one of these .colpkg files and crossed my fingers...

holy shit it worked!

What about the assets though? I figured the best strategy would be to put them in their right place before anybody noticed they were missing. But where might that place be?

It took me awhile to find ~/.local/share/Anki2/User 1/collection.media . I put all my images in there.

a surprise migration?

I need to be "upgraded to the v3 scheduler?". O.K. I click a button and its immediately done.

At this point I open a deck to "study" and I'm curious if my images will be correctly linked up. Hallelujah

now its time to sync up to AnkiWeb

Now that I know my images won't all be missing I'm confident to sync back up to AnkiWeb. First I have to provide my credentials:

This confirmation seems unnecessary but 'Yes'!

So far so good! Everything shows up on the web-side.

sync back down to Android device

finally? hopefully?

After providing my credentials my data synced back down to my Android device, where I am using AnkiDroid.

lessons learned

  1. Using open-source software often requires a little more grit than the average consumer wants to put in. This is inherently the distinction between something you pay for vs a free tool that is being given to you.
  2. Developing and maintaining an open-source project, even as seemingly simple as a flashcard app, is actually more work than anyone assumes. All those developers are asking for donations because it is starting to feel like work.
  3. Large platforms often have to implement policies that make things hard for developers to do simple things, usually due to security. In this case the Anki developers simply wanted to put user data into a different directory so that Android would not offer to "clean up" (delete) the user data along with the app.

Was it worth it? Yeah probably. I spent a lot of time creating my custom card decks and I am planning on getting back into the practice.

I hope this can help someone else recover their Anki data. Happy studying.