A cross-platform console application for backing up Git repositories to local storage.
- π Cross-Platform: Works on Windows, Linux, and macOS
- π Authentication Support: Access both public and private repositories with Personal Access Token
- π― Flexible Filtering:
- Download private repositories only
- Exclude archived repositories
- Filter by specific criteria
- π₯οΈ Command-Line Interface: Built with Spectre.Console.Cli for robust argument parsing
- π Extensible Architecture: Core/Provider pattern allows easy addition of other Git hosting providers (GitLab, Bitbucket, etc.)
# Download all public repositories for a user (this is for GitHub))
SimpleRemoteGitRepoBackup -username PureKrome
# Download with authentication (access private repos)
SimpleRemoteGitRepoBackup -username PureKrome -token ghp_xxxxxxxxxxxx
# Download only private repositories
SimpleRemoteGitRepoBackup -username PureKrome -token ghp_xxxxxxxxxxxx --private-only
# Specify custom directory and include archived repos
SimpleRemoteGitRepoBackup -username PureKrome -token ghp_xxxxxxxxxxxx --private-only -directory /path/to/backups --include-archivedSimpleRemoteGitRepoBackup [OPTIONS]
| Option | Short | Description | Default |
|---|---|---|---|
--username <USERNAME> |
-u |
Git Repo Owner/UserName | - |
--token <TOKEN> |
-t |
Git Repo Personal Access Token for authentication | None (public access) |
--directory <PATH> |
-d |
Target directory for downloads | ~/CodeBackup |
--private-only |
Download only private repositories | false |
|
--include-archived |
Include archived repositories | false (excluded by default) |
- Go to GitHub Settings β Developer Settings β Personal Access Tokens β Tokens (classic)
- Click "Generate new token"
- Give it a descriptive name (e.g., "CodeBackup")
- Select the following scopes:
repo(for private repositories)public_repo(for public repositories - included inrepo)
- Click "Generate token"
- Important: Copy the token immediately - you won't be able to see it again!
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
dotnet run --project WorldDomination.CodeBackup.Console backup PureKrome --token $GITHUB_TOKEN# Clone the repository
git clone https://github.com/yourusername/WorldDomination.CodeBackup.git
cd WorldDomination.CodeBackup
# Build the solution
dotnet build
# Run the application
dotnet run --project WorldDomination.CodeBackup.Console -username <username> ...Create a self-contained executable:
# For Windows
dotnet publish WorldDomination.CodeBackup.Console -c Release -r win-x64 -o $PWD/publish
# For Linux
dotnet publish WorldDomination.CodeBackup.Console -c Release -r linux-x64 -o $PWD/publish
# For macOS
dotnet publish WorldDomination.CodeBackup.Console -c Release -r osx-x64 -o $PWD/publishAfter publishing, you can run the executable directly:
# Windows
.\publish\SimpleRemoteGitRepoBackup.exe --username PureKrome ...
# Linux/macOS
./publish/SimpleRemoteGitRepoBackup --username PureKrome ...- .NET 9.0 SDK or later
- A GitHub account
- (Optional) GitHub Personal Access Token for private repositories
- Purpose: Contains platform-agnostic interfaces and models
- Key Interfaces:
IRepositoryProvider: Contract for repository providers
To add support for other Git hosting providers (GitLab, Bitbucket, etc.):
- Create a new project:
WorldDomination.CodeBackup.GitLab - Implement
IRepositoryProviderinterface - Add provider-specific authentication and API calls
- Register in the console application
Example:
public class GitLabRepositoryProvider : IRepositoryProvider
{
public string ProviderName => "GitLab";
// Implement interface methods...
}Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
[Your License Here]