Supermemo backup using Git

From Pleasurable Learning
Jump to navigation Jump to search

SuperMemo is friendly for GIT

  • Screenshot of files inside my main SuperMemo collection. There are 23137 HTML files, basically rich text for elements, only need 235.5MB, that means each file has a filesize of 10 KB.
    SuperMemo data structure is spread across many tiny files and folders, instead of one big file like Anki collection database.
    • HTML files are relatively small.
    • Every file change is saved, so if you change a big file often, you would need rediculously huge storage for git. Imagine 20 copies of 100mb file vs 400 copies of a 150kb file.
  • GIT saves every file in one commit (backup), so there are:
    • No stray files unlike cloud drives, which could leave one or two files hanging; if they happen to be important files, this could corupt your whole collection.
    • You can quickly respore the backup at any point in the past, without having full copies of the whole collection every time.
    • Unlike could drives, ff one file fails to be commited, the entire commit fails. So you ensure the backup is free from corruption.

Pros of using GIT for backup

  • Once everyting is set up, you can backup your daily session within a few seconds.
  • You can use the same collection(s) in multiple computers.
  • You have local and cloud backup.
  • You can search in your GIT repository for any deleted file regardless of how long has been deleted, as long as it was after the first commit.

Cons of using GIT for backup

  • Git often provides smaller storage spaces for free.
    • Biggest one fore free is Gitlab which provides 10gb which sould be enough for all your SuperMemo files excluding videos.
    • You can skip large files, such as videos, PDF files etc, by using the secondary storage. You may backup the secondary storage with cloud services like Google drive, One drive etc.
  • You need connection to the internet in order to sync changes.
  • It requires an initial set up that may be non-trivial for non-tech savy users.
    • This pages tries to mitigate this fear or aversion.


Seting up a Git backup using Gitlab

I strongly discourage naming the files "pull.bat" and "push.bat" as both will be next to each other, increasing the chances to missclick leading to potential local deletions.

Synching made with current computer i.e. updating backup

sm-push.bat to sync your changes to the cloud

git add -A && git commit -m "Update"
git push


Synching changes made from another computer

pull-sm.bat to get the cloud version to your computer.

git pull

Resolving conficts

If you ar eusing multiple computers, it is likely you ma face marge conflicts.

Resolve-conflicts neded when different computers used SuperMemo asynchronously.

git reset --hard
git checkout -b temp
git branch -D main
git fetch
git checkout main


If you skip one or a few days, you might forget which computer you used last time. I strongly suggest to use commit naming convention for each computer you use so you know which computer has the current state of your collection, in other words, which computer you used last time with SuperMemo.


Resolving 502 HTTP error

The 502 HTTP error is triggered whent rying to sync your collection to git that is too large. The solution is what I call incremental commit & push.