To use this backup tool, you need to create a GitHub Personal Access Token (PAT) with appropriate permissions.
-
Go to GitHub Settings
- Navigate to GitHub.com
- Click on your profile picture in the top-right corner
- Select Settings
-
Access Developer Settings
- Scroll down in the left sidebar
- Click on Developer settings (at the bottom)
-
Generate New Token
- Click on Personal access tokens → Tokens (classic)
- Click on Generate new token → Generate new token (classic)
-
Configure Token Settings
- Note: Give your token a descriptive name (e.g., "GitHub Backup Tool")
- Expiration: Choose an expiration period (recommended: 90 days or custom)
-
Select Scopes For backing up your repositories, select the following scopes:
- ✅
repo- Full control of private repositories- This includes:
repo:status,repo_deployment,public_repo,repo:invite,security_events
- This includes:
For backing up organization repositories, you may also need:
- ✅
read:org- Read org and team membership, read org projects
- ✅
-
Generate and Copy Token
- Scroll to the bottom and click Generate token
- IMPORTANT: Copy the token immediately - you won't be able to see it again!
- Store it securely (e.g., in a password manager)
-
Follow steps 1-2 above
-
Click on Personal access tokens → Fine-grained tokens
-
Click Generate new token
-
Configure:
- Token name: Descriptive name
- Expiration: Set appropriate expiration
- Repository access:
- Select "All repositories" to backup all your repos
- Or select specific repositories you want to backup
- Permissions:
- Under "Repository permissions":
- Contents: Read-only access
- Metadata: Read-only access (automatically included)
- Under "Repository permissions":
-
Click Generate token and copy it immediately
export GITHUB_TOKEN="your_token_here"Then run the backup tool without the --token flag:
cargo run --release -- --owner yourusernamecargo run --release -- --token your_token_here --owner yourusernameSet the environment variable in your shell, then:
mise run run- Store tokens securely (use a password manager or environment variables)
- Set appropriate expiration dates
- Revoke tokens when no longer needed
- Use the minimum required scopes
- Rotate tokens regularly
If your token is compromised or no longer needed:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Find the token in the list
- Click Delete or Revoke
- Confirm the action
- Your token may have expired
- The token might be invalid or incorrectly copied
- Generate a new token and try again
- You might not have access to the repository/organization
- Check that you selected the correct scopes when creating the token
- Verify the username/organization name is correct
- GitHub has API rate limits (5,000 requests/hour for authenticated requests)
- The tool handles pagination automatically
- If you hit the limit, wait an hour or use a different token