Backup all Gists from GitHub

6 Apr '20

While GitHub hasn’t ever let me down, it’s always a good idea to have backups of any code. So, a quick script to do this for gists.

You’ll need to set up a personal access token in GitHub first for the script (the scope it needs is “gist”). I’ve done this because it’s the right way to do it, and I can’t test username and password, since I have two factor authentication (2FA) enabled - you do, too, right?

The script will pull all gist descriptions, files, and comments, including private gists (well, it’d be a bad backup script if it didn’t). This is the structure:

.
├── d7b4378417f4a10a75dd7245ec557240
│   ├── save-gists.py
│   └── comments.md
...
└── index.md

Naturally, the script is a gist:

git

Newer Older