Code Monkey home page Code Monkey logo

github-mirroring's Introduction

GitHub mirroring

A simple python script to mirror all of an organization's GitHub repositories.

This script was designed to copy all commits from GitHub to our local Gitolite server, so we always have a full archive of our GitHub account, but it will also let you just archive your GitHub repositories locally. There is a more background in this Medium post.

Getting started

To get started, clone the repository and run python github-mirror.py -h for usage information. The only additional dependency is requests. More specifically:

  1. git clone https://github.com/dragonfly-science/github-mirroring.git to get the code
  2. pip install requests to install dependencies
  3. cd github-mirroring change into the source directory (or copy the script where you like)
  4. python github-mirror.py -h run with the help flag for usage information

In order for it to access private repositories, the GitHub access token for the account needs to be set as the environment variable GITHUB_OAUTH_TOKEN.

Minimal examples

Backup up your public repositories to local storage

python github-mirror.py yourname -a user --repository-type=public

Backup your organisation's private repositories to local storage

GITHUB_OAUTH_TOKEN=becb84bde335a242707af71dae41a24f python github-mirror.py yourorganisation

First, generate a GitHub Personal Access Token, by going to Account settings > Applications on github.com. Hit the Generate new token button. The default permissions of repo, public_repo, and user are sufficient for the simple case. If you are using the webhooks, you will also need the write:repo_hook permission. Copy the generated key, a random string of characters like becb84bde335a242707af71dae41a24f. This key will need to be in the environment variable GITHUB_OAUTH_TOKEN when the command is run.

The usual warnings apply

Some effort has been made to make the script work in a range of situations, however it has only been tested in our specific usecase - mirroring an organisation's private repositories to a local Gitolite mirror. We are all care, no responsibility. Please make sure you understand what the script does before letting it loose.

github-mirroring's People

Contributors

edwardabraham avatar

Watchers

Spencer Tom Tafadzwa Chirume avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.