Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.3 KB

README.md

File metadata and controls

51 lines (34 loc) · 1.3 KB

Backup federal git repos

This script creates git bundle files for all repositories in a GitHub organization. Git bundles are complete backups of git repositories that can be cloned or fetched from like any other git remote.

Getting started

# install asdf: https://asdf-vm.com/guide/getting-started.html

# activate python version defined in .tool-versions
asdf install

# initialize and activate virtual env
python -m venv .venv
source .venv/bin/activate

# install python requirements
pip install -r requirements.txt

# set up environment variables
cp .env.example .env
# edit .env and add your GitHub token

# run the backup script (replace ORGNAME with target GitHub organization)
python backup.py ORGNAME

Usage

The script will create .bundle files in the bundles/ORGNAME directory. These bundles can be used to restore repositories:

# To clone a new repository from a bundle
git clone repo-name.bundle

# To fetch updates from a bundle into an existing repository
git fetch repo-name.bundle

Configuration

The script requires two configurations:

  1. GitHub Token: Create a .env file based on .env.example and add your GitHub personal access token
  2. Organization Name: Provided as a command line argument when running the script

Example:

python backup.py usds