Skip to main content
  1. Technical guides/

Automatic Backups of my GitHub Repositories

·2 mins·

I have all of my code on GitHub. Microsoft could at any time decide to just ban me and I would loose access to it all. It unlikely, but it could happen.

There are many obvious solutions to this:

  1. take my code to a more trustworthy vendor
  2. self-host my git
  3. backup/mirror github repositories

For the moment I went with the backup option.

Requirements #

Backups should happen automatically, for every repo in my account. I don’t want to think about it.

Setup #

I picked the tool gickup for the job. I have it running on my homeserver, so the repos are part of it’s backup scheme.

I installed the latest release:

wget https://github.com/cooperspencer/gickup/releases/download/v0.10.39/gickup_0.10.39_linux_386.tar.gz
tar -xzf gickup_0.10.39_linux_386.tar.gz

Created and tested the config (docs):

# gickup.yml
source:
  github:
    - user: jneidel
      token: github_pat_...
      issues: true
      filter:
        excludeforks: true
destination:
  local:
    - path: /root/backup/github-repos
      bare: true

Invoke with gickup gickup.yml.

For authentication I created a personal access token with the permissions shown below. I tried using my git ssh key, which worked for cloning, but ran into API rate limits. The token is more secure also, since it’s read-only.

Permissions for the github personal access token

I want this to run once a week, so I setup execution with cron: 0 16 * * 0.

Conclusions #

The one-time setup was easier than expected. It does not require maintenance so I don’t have to think about this again.