A Python script to backup all repos (public or private) of a user.


  • Clone public and private repos
  • Load specified SSH key before starting backup
  • Automatically lists all repos from Github's API
  • Personal access token authentication to Github's API


$ ./ -h
usage: [-h] -u USERNAME [-d DIRECTORY] [-S SSH_KEY] [-T TOKEN] [-P] [-v]

Description message

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        Target github username
  -d DIRECTORY, --directory DIRECTORY
                        Local directory to store repos into.
  -S SSH_KEY, --ssh-key SSH_KEY
                        SSH key to authenticate with.
  -T TOKEN, --token TOKEN
                        Github personal access token, necessary to list your private repos.
  -P, --pull            Perform git pull on existing directories.
  -v, --verbose         Verbose mode. (default: False)


Cloning all public repos of a user

./ -u TargetUser -d ./SavedRepos/ --pull

Cloning all your public and private repos

./ -u YourUserName -d ./SavedRepos/ -S ~/.ssh/github -v --pull

How to create a personal access token

To create a personal access token you need to go in Settings > Developer settings > Personal access tokens in your account, or at

Everything is in Github's docs here:


Pull requests are welcome. Feel free to open an issue if you want to add other features.

GitHub - p0dalirius/GithubBackupAllRepos at
A Python script to backup all repos (public or private) of a user. - GitHub - p0dalirius/GithubBackupAllRepos at