Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[TUT] How to create your own daily complete backup of Anki

This can be used to backup any directory on your computer (not just Anki). Just take care of the size of the directory you are backing up (in case it is too big you may run out of space).


  1. MacOS, Windows or Linux with Unix environment tools

    1. bash
    2. zip
    3. rm
    4. cmp
    5. mkdir
    6. tail
    7. ps
    8. grep
    9. awk
    10. sleep
    11. xargs
    12. ts (package moreutils, sudo apt-get install moreutils or brew install moreutils)
  2. Download the following files in the same directory:

    1. (
    2. (

After downloading the files, edit the file and replace the full path inside the variables:

  1. export SRCDIR="" by the directory where your Anki files are.
  2. export DESTDIR="" by the location where you would like to save the backups.

Now, you need to schedule/configure the script to run. It could be one time per day or several times:

  1. On Linux you can see the tutorial How to Schedule Tasks on Linux: An Introduction to Crontab Files and set it to run the script (just remember to use the full path to the script).

  2. On Mac OS/Linux you watch the video tutorial Linux/Mac Tutorial: Cron Jobs - How to Schedule Commands with crontab and set it to run the script.

  3. On Windows you can create a Task Scheduling task:

    1. Go to the Start Menu and search for Task Scheduler


    2. Download the files:

      1. (silent_run.vbs)
      2. (AnkiBackupDailyTask.xml)
    3. Edit the downloaded file AnkiBackupDailyTask.xml and:

      1. Replace the full path to silent_run.vbs by the full location of the file silent_run.vbs on your computer

      2. Replace the full path to sh.exe by the full location of the file bash.exe on your computer

      3. Replace the full path to by the full location of the file on your computer

    4. Now to go the Task Scheduler menu Action -> Import Task... and select the file AnkiBackupDailyTask.xml


    5. If you would like, you can configure the time you want to run the backup by selecting Task Scheduler Library -> Backup Anki -> Properties -> Triggers -> Edit.


    6. If your computer is not on/started/running at the time you select, the backup will run automatically on the next time you start your computer after the time. You can change that by going to Task Scheduler Library -> Backup Anki -> Properties -> Settings:



  1. You can see the logs of the backups by opening the file ankibackup.log created automatically at the same directory where your file is on.

  2. See Managing Files and Your Collection to learn where your Anki files are located. For example, on Windows this location usually is: /cygdrive/C/Users/YourUserName/AppData/Roaming/Anki2

  3. The /cygdrive/... thing is used because on this example I am on Windows using the Unix environment Cygwin and a Windows full path as C:\Users\... has to be converted to the format /cygdrive/C/Users/....

  4. If Anki is already running, the script will wait until Anki closes and then run the backup. If a new schedule of the backup run while there is an older scheduling waiting for Anki to exit, the latest scheduling will exit with error 11 while the first one will still/be kept waiting for Anki to exit.

Related to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment