Skip to content
A simple python script to back-up all the repos of a user to a local drive
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

GitHub Backup-All

A simple python code to backup up all repositories owned by user, user's organizations, and repositories owned by others which user has contributed. The code will clone new repositories if they do not exist in the local directory or pull new commits from GitHub if the repository already exists in the local directory. If a repository has submodules, they will be updated too.

What you just need to do is to run the code whenever you need to backup your GitHub repositories.

Backup will have the following structure:

+ GitHub
  + personal
    - repo_1
    - repo_2
  + contributed
    - repo_1
    - repo_2
  + organization_1
    - repo_1
    - repo_2
  + organization_2
    - repo_1
    - repo_2


  1. Install dependencies
pip install pygithub # GitHub API
  1. Create a personal access token for GitHub. Copy the token and do the following in the terminal before running the code. You MUST to do this every time you run the code. You can skip this if you add the line to ~/.bashrc or ~/.zshrc.
export GH_ACCSS_TKN=personal_access_token_generated_in_GitHub
  1. Make sure that you are connected to GitHub with an ssh key.


Run the code:


For help and arguments, run:

python -h
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.