-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Add support for backing up GitHub repository settings, account settings, and GitHub Pages configuration to provide a more comprehensive backup solution.
Problem Statement
Currently, python-github-backup backs up repository content, issues, pull requests, releases, and other metadata, but it doesn't capture important configuration settings that are crucial for disaster recovery scenarios:
Repository settings (branch protection rules, webhooks, deploy keys, etc.)
GitHub Pages configuration and settings
Account-level settings and preferences
Organization settings (for organization backups)
Proposed Solution
- Repository Settings Backup
Add a new --settings flag to backup repository-level configurations:
API Endpoints to utilize:
GET /repos/{owner}/{repo} - Repository metadata and settings
GET /repos/{owner}/{repo}/branches/{branch}/protection - Branch protection rules
GET /repos/{owner}/{repo}/keys - Deploy keys
GET /repos/{owner}/{repo}/collaborators - Repository collaborators and permissions
GET /repos/{owner}/{repo}/teams - Team access (for organizations)
GET /repos/{owner}/{repo}/environments - Deployment environments
Output structure:
repositories/ {repo-name}/ settings/ repository.json # Basic repo settings branch-protection.json # Branch protection rules deploy-keys.json # Deploy keys collaborators.json # Collaborators and permissions teams.json # Team access (orgs) environments.json # Deployment environments
2. GitHub Pages Backup
Add a new --pages flag to backup GitHub Pages configuration:
API Endpoints:
GET /repos/{owner}/{repo}/pages - Pages configuration
GET /repos/{owner}/{repo}/pages/builds - Pages build history
Output structure:
repositories/ {repo-name}/ pages/ configuration.json # Pages settings (source, domain, HTTPS, etc.) builds.json # Build history
3. Account Settings Backup
Add a new --account-settings flag for user/organization settings:
API Endpoints:
GET /user - User profile and settings (already partially used)
GET /user/keys - SSH keys
GET /user/gpg_keys - GPG keys
GET /orgs/{org} - Organization profile and settings
GET /orgs/{org}/members - Organization members
GET /orgs/{org}/teams - Organization teams
Output structure:
account/ profile.json # User/org profile ssh-keys.json # SSH keys gpg-keys.json # GPG keys members.json # Organization members (if org) teams.json # Organization teams (if org)
Implementation Details
Command Line Arguments
# Backup repository settingsgithub-backup user --settings# Backup GitHub Pages configurationgithub-backup user --pages# Backup account-level settingsgithub-backup user --account-settings# Include everything (add to --all flag)github-backup user --all
Code Changes Required
Add new command line arguments in parse_args():
parser.add_argument( "--settings", action="store_true", dest="include_settings", help="include repository settings in backup")parser.add_argument( "--pages", action="store_true", dest="include_pages", help="include GitHub Pages configuration in backup")parser.add_argument( "--account-settings", action="store_true", dest="include_account_settings", help="include account-level settings in backup")
Add new backup functions:
def backup_repository_settings(args, repo_cwd, repository, repos_template): # Implementation for repository settings backup def backup_pages_configuration(args, repo_cwd, repository, repos_template): # Implementation for GitHub Pages backup def backup_account_settings(args, output_directory): # Implementation for account settings backup
Update backup_repositories() function to call new backup functions when flags are set.
Update --all flag logic to include new backup types.
Benefits
Complete disaster recovery: Ability to restore not just content but entire repository configuration
Compliance: Better audit trail for repository settings changes
Migration support: Easier repository migration between GitHub instances
Documentation: Settings backup serves as documentation of current configuration
Considerations
API rate limits: Additional API calls will consume more rate limit quota
Authentication: Some settings require specific scopes/permissions
Incremental backup: Settings don't change frequently, so incremental logic should be applied
Organization permissions: Some organization settings require admin access
Acceptance Criteria
Repository settings can be backed up with --settings flag
GitHub Pages configuration can be backed up with --pages flag
Account settings can be backed up with --account-settings flag
New backup types are included in --all flag
Backup respects existing --skip-existing logic
Error handling for insufficient permissions
Documentation updated with new features
Tests added for new functionality
Related Issues
This feature would complement the existing backup functionality and address gaps in comprehensive GitHub backup coverage.
Priority: Medium Effort: Medium (requires API integration and new backup logic) Impact: High (significantly improves backup completeness) </tool_use> </tool_use>
I've created a comprehensive issue for backing up GitHub settings. The issue covers three main areas:
Key Features Proposed:
Repository Settings Backup (--settings flag)
Branch protection rules
Deploy keys
Collaborators and permissions
Deployment environments
Webhooks (already partially covered by --hooks)
GitHub Pages Backup (--pages flag)
Pages configuration (source, custom domain, HTTPS settings)
Build history
Account Settings Backup (--account-settings flag)
SSH and GPG keys
Organization members and teams
User/organization profiles
Implementation Approach:
New command line flags
Additional API endpoints
Structured JSON output
Integration with existing --all and --skip-existing logic
The issue includes:
✅ Clear problem statement
✅ Detailed technical implementation
✅ API endpoints to use
✅ File structure for outputs
✅ Code examples
✅ Benefits and considerations
✅ Acceptance criteria