I use AnkiWeb to sync my decks across various devices. I want to set up an additional cron job from a Linux machine to back up my data from AnkiWeb to a local file for safekeeping.
I read here on this forum[1] that it suffices to back up the Anki data directory, which on my workstation (where I have installed Anki as a flatpak) is ~/.var/app/net.ankiweb.Anki/data/Anki2
. Great!
Except one problem … I actually almost never open the Anki desktop app, and do all my studying on mobile. The main reason I have Anki installed is so that my desktop has a way to talk to the AnkiWeb server and update itself so that I can run this backup.
So, my question is, is there a command I can run at the command line inside of a cron job that will trigger Anki to do a sync that I can issue prior to backing up the Anki data directory?
What I’ve tried
In a desktop session, running timeout 60 flatpak run net.ankiweb.Anki
is enough—it loads up the full GUI, lets it sync automatically, then kills it.
But in my backup script, this fails with The application failed to start because no Qt platform plugin could be identified
. I tried setting QT_QPA_PLATFORM=offscreen
but this doesn’t work either:
> QT_QPA_PLATFORM=offscreen timeout 60 flatpak run net.ankiweb.Anki
Python module pip_system_certs is not installed. System certificate store and custom SSL certificates may not work. See: https://github.com/ankitects/anki/issues/3016
Starting Anki 25.02.4...
Qt warning: setHighDpiScaleFactorRoundingPolicy must be called before creating the QGuiApplication instance
2025-05-26 11:04:25,688:INFO:aqt.mediasrv: Serving on http://127.0.0.1:46403
Qt warning: QRhiGles2: Failed to create temporary context
Qt warning: QRhiGles2: Failed to create context
Qt warning: This plugin does not support createPlatformVulkanInstance
Qt warning: QVulkanInstance: Failed to initialize Vulkan
Qt warning: Unable to detect GPU vendor.
[2:21:0526/110425.878038:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Starting main loop...
Qt warning: This plugin does not support propagateSizeHints()
Qt warning: This plugin does not support raise()
Qt warning: This plugin does not support propagateSizeHints()
Qt warning: This plugin does not support propagateSizeHints()
Qt warning: This plugin does not support propagateSizeHints()
Qt warning: This plugin does not support propagateSizeHints()
Qt warning: This plugin does not support propagateSizeHints()
As a new user, I’m not allowed to post links, but if you search “Automatic deck backups (export) from the command line (Linux)” the relevant post will come up. Maybe a mod can edit a link in for me. ↩︎