This tool automatically backs up GitHub repositories from a specified user's starred list. It includes features like repository size checking, retry mechanisms for large repositories, and detailed backup status reporting.
- Backs up repositories from a user's GitHub starred list
- Shows repository sizes before downloading
- Handles large repositories with optimized Git settings
- Provides detailed backup status and error reporting
- Supports shallow cloning for faster initial backups
- Automatic retry mechanism for failed downloads
- Detailed backup metadata tracking
- Install the required dependencies:
pip install -r requirements.txt
-
Make sure you have Git installed on your system
-
You need a GitHub token to run the script. You can obtain one by visiting https://github.com/settings/tokens and creating a new token with the
repo
permission. -
Create a
.env
file in the project directory and add your GitHub token:
GITHUB_TOKEN=your_token_here
Run the script with default settings:
python github_backup.py
Or specify a different user and list name:
python github_backup.py username listname
- Username: "jing8263xiao"
- List name: "backup"
The script will:
- Configure Git settings for optimal performance
- Display repository sizes before downloading
- Create or update repositories in the
backups
directory - Show a detailed summary of successful and failed backups
- Generate a
backup_metadata.json
file containing:- Timestamp of the last backup
- List of successfully backed up repositories
- List of failed repositories with error messages
- Total number of processed repositories
- Success and failure counts
The script includes several features to handle common issues:
- Automatic retries for network-related failures
- Exponential backoff between retry attempts
- Shallow cloning for large repositories
- Optimized Git settings for better performance
- Detailed error reporting for troubleshooting
backups/
├── repository1.git/
├── repository2.git/
├── ...
└── backup_metadata.json