Backup GitHub repositories

You should also backup your GitHub repositories. The following Python-script will query the GitHub-api to get a list of your repositories. Next this script will run "git pull" on all of them.
I run this script daily on my NAS.

import subprocess
import requests
import base64
import subprocess
import os

api_output = requests.get("https://api.github.com/users/{github-username}/repos")

for project in api_output.json():
    print(project["clone_url"])

    local_path = os.path.join("github", project["name"])

    if os.path.isdir(local_path):

        try:
            output = subprocess.check_output(
                ["git", "pull"], cwd=local_path)
            print(output)
        except:
            print("error")

    else:

        output = subprocess.check_output(
            ["git", "clone", project["clone_url"]], cwd="github")
        print(output)