Automatic deck backups (export) from the command line (Linux)

I want to export all of the decks of my user, and store them safely as an offline backup. I want to run it from a script periodically (probably through a cronjob), instead of having to manually export the decks from the Anki desktop interface (thus it has to run in the command line, preferably without Anki running). Are there any good tools to achieve that? From what I’ve seen, all the API interfaces for Anki focus on flashcard creation or other functionalities I have no interest in, and none seem to have this functionality. But maybe I missed something, thus I’m asking here. I am using a GNU/Linux operating system, so I’m only interested in tools that can be used in that environment.
Although I might be wrong (please correct me if so), but I take it that exporting a deck is the proper way of backing it up? I’ve seen people backing up their entire Anki directory, but I want to just store the decks.

1 Like

Okay, after taking a different angle in my search, it turns out that Anki makes backups of the entire collection automatically in .colpkg files. But the manual says:

Automatic backups do not protect against disk or computer failure, and do not extend to your media. To keep your collections safe, please consider making manual backups too.

So I take it that these are without any sound/image files? In that case, it wouldn’t be useful for me in this situation.

Copying your ~/.local/share/Anki2 folder (maybe excluding the addons21 subfolder) with any file transfer utility (like rsync) should work. You should do that only when Anki is closed.

Please see Anki Manual

1 Like