Awesome Open Source
Awesome Open Source

soba: backup hosted git repositories

Build Status Codacy Badge Go Report Card


soba is tool for backing up private and public git repositories hosted on the most popular hosting providers. It generates a git bundle that stores a backup of each repository as a single file.

An unchanged git repository will create an identical bundle file so bundles will only be stored if a change has been made and will not produce duplicates.

latest updates

0.0.19 released 2021-08-29
Resolve packaging issues

0.0.18 released 2021-08-29
Fix issue that limited bitbucket repository discovery to ten

Supported OSes

Tested on Windows 10, MacOS, and Linux (amd64).
Not tested, but should also work on builds for: Linux (386, arm386 and arm64), FreeBSD, NetBSD, and OpenBSD.

supported providers

  • BitBucket
  • GitHub
  • GitLab


soba can be run from the command line or as docker container. In both cases the only configuration required is an environment variable with the directory in which to create backups, and additional to define credentials for each the providers.

On Windows 10:

  • search for 'environment variables' and choose 'Edit environment variables for your account'
  • choose 'New...' under the top pane and enter the name/key and value for each of the settings

On Linux and MacOS you would set these using:

$ export GIT_BACKUP_DIR="/repo-backups/"

To set provider tokens see below.

run using command line

Download the latest release here and then install:

$ install <soba binary> /usr/local/bin/soba

After setting GIT_BACKUP_DIR, set your provider token(s) as detailed here.

and then run:

$ soba

run using docker

Using docker enables you to run soba without anything else installed.

Docker requires you pass environment variables to the container using the '-e' option and that you mount your preferred backup directory. For example:

$ docker run --rm -t \
             -v <your backup dir>:/backup \
             -e GIT_BACKUP_DIR='/backup' \

To hide credentials, you can instead use exported environment variables and specify using this syntax:

$ docker run --rm -t \
             -v <your backup dir>:/backup \
             -e GIT_BACKUP_DIR='/backup' \
             -e GITHUB_TOKEN=$GITHUB_TOKEN \
             -e GITLAB_TOKEN=$GITLAB_TOKEN \

scheduling backups

Backups can be scheduled to run by setting an additional environment variable: GIT_BACKUP_INTERVAL. The value is the number of hours between backups. For example, this will run the backup daily:


if using docker then add:


Note: the interval is added to the start of the last backup and not the time it finished. Therefore, ensure the interval is greater than the duration of a backup.

rotating backups

A new bundle is created every time a change is detected in the repository. To keep only the x most recent, use the following provider specific environment variables:


setting provider tokens

On Linux and MacOS you can set environment variables manually before each time you run soba:

$ export NAME='VALUE'

or by defining in a startup file for your shell so they are automatically set and available when you need them. For example, if using the bash shell and running soba as your user, add the relevant export statements to the following file:


and run:

$ source /home/<your-user-id>/.bashrc
Provider Environment Variable(s) Generating token
GitHub GITHUB_TOKEN instructions
GitLab GITLAB_TOKEN instructions

run on Synology NAS

Tested on DS916+

  1. Create a directory on your NAS for backing up Git repositories to
  2. Install Docker from the Synology Package Center
  3. Open Docker and select 'Image'
  4. Select 'Add' from the top menu and choose 'Add From URL'
  5. In 'Repository URL' enter 'jonhadfield/soba', leave other options as default and click 'Add'
  6. When it asks to 'Choose Tag' accept the default 'latest' by pressing 'Select'
  7. Select image 'jonhadfield/soba:latest' from the list and click 'Launch' from the top menu
  8. Set 'Container Name' to 'soba' and select 'Advanced Settings'
  9. Check 'Enable auto-restart'
  10. Under 'Volume' select 'Add folder' and choose the directory created in step 1. Set the 'Mount Path' to '/backup'
  11. Under 'Network' check 'Use the same network as Docker Host'
  12. Under 'Environment' click '+' to add each of the following:
  • variable GIT_BACKUP_DIR Value /backup
  • variable GIT_BACKUP_INTERVAL Value [hours between backups]

Provider Specific

  • variable BITBUCKET_USER Value [BitBucket User] (if using BitBucket)
  • variable BITBUCKET_KEY Value [BitBucket Key] (if using BitBucket)
  • variable BITBUCKET_SECRET Value [BitBucket Secret] (if using BitBucket)
  • variable BITBUCKET_BACKUPS Value [Number of backups to keep for each repo]
  • variable GITHUB_TOKEN Value [GitHub token] (if using GitHub)
  • variable GITHUB_BACKUPS Value [Number of backups to keep for each repo]
  • variable GITLAB_TOKEN Value [GitLab token] (if using GitLab)
  • variable GITLAB_BACKUPS Value [Number of backups to keep for each repo]
  1. Click 'Apply'
  2. Leave settings as default and select 'Next'
  3. Check 'Run this container after the wizard is finished' and click 'Apply'

The container should launch in a few seconds. You can view progress by choosing 'Container' in the left-hand menu, select 'soba', choose 'details' and then click on 'Log'

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Go (198,208
Golang (33,547
Github (8,214
Git (7,654
Backup (2,226
Gitlab (1,315
Repository (1,096
Bundle (805
Bitbucket (376
Nas (209
Synology (189
Git Bundle (3
Related Projects