This repo provides a script for backing up all git repos from a specified organization or user.
- Python 3.7+
- Git installed (and configured to access the repositories)
git clone git@github.com:UMCU-Digital-Health/backup-git.git
cd backup-git
uv syncCreate a .env file in the project root with the following content:
GITHUB_TOKEN=your_github_token_here
ORGANIZATION=your_organization_or_username_hereWithout this token, the script will only be able to access public repositories.
Run the script:
uv run main.pyTo schedule this script to run periodically, you can use cron jobs as follows:
crontab -eAnd add the following line to run the script daily at 3 AM:
0 3 * * * path/to/venv/bin/python /path/to/your/script/main.py > /path/to/your/logfile.log 2>&1To get a fine-grained token on GitHub go to https://github.com/settings/personal-access-tokens and generate a new token that requires read-only access on contents of all repositories.
This project is licensed under the MIT License.