GitHubBackupTool
This tool creates a local backup of repositories of a given GitHub user with some options to filter based on some conditions. You can also use it to backup all repositories of an organization of you created a personal access token with the right permissions under there.
Install / Use
/learn @michaelmsonne/GitHubBackupToolREADME
GitHubBackupTool
<p align="center"> <a href="https://github.com/michaelmsonne/GitHubBackupTool"><img src="https://img.shields.io/github/languages/top/michaelmsonne/GitHubBackupTool.svg"></a> <a href="https://github.com/michaelmsonne/GitHubBackupTool"><img src="https://img.shields.io/github/languages/code-size/michaelmsonne/GitHubBackupTool.svg"></a> <a href="https://github.com/michaelmsonne/GitHubBackupTool"><img src="https://img.shields.io/github/downloads/michaelmsonne/GitHubBackupTool/total.svg"></a> </p> <div align="center"> <a href="https://github.com/michaelmsonne/GitHubBackupTool/issues/new?assignees=&labels=bug&template=01_BUG_REPORT.md&title=bug%3A+">Report a Bug</a> · <a href="https://github.com/michaelmsonne/GitHubBackupTool/issues/new?assignees=&labels=enhancement&template=02_FEATURE_REQUEST.md&title=feat%3A+">Request a Feature</a> . <a href="https://github.com/michaelmsonne/GitHubBackupTool/discussions">Ask a Question</a> </div>Table of Contents
Contents
Outline the file contents of the repository. It helps users navigate the codebase, build configuration and any related assets.
| File/folder | Description |
|-------------------|---------------------------------------------|
| \GithubBackup | Source code. |
| \Installer | Installer project. |
| .gitignore | Define what to ignore at commit time. |
| CHANGELOG.md | List of changes to the sample. |
| CONTRIBUTING.md | Guidelines for contributing to the project. |
| README.md | This README file. |
| SECURITY.md | Security file. |
| LICENSE | The license for the project. |
Introduction
This tool creates a local backup of repositories of a given GitHub user with some options to filter based on some conditions. You can also use it to backup all repositories of an organization of you created a personal access token with the right permissions under there.
All repositories of the given GitHub API key will be concurrently cloned to the provided destination folder if selected.
If you don´t provide a destination folder in the argument, the backup will be created in your current folder there the application is executed.
While your code is perfectly safe on the GitHub infrastructure, there are cases where a centralized local backup of all projects and repositories is needed. These might include Corporate Policies, Disaster Recovery and Business Continuity Plans.
By using the GitHubBackupTool, you can automate the process of creating backups of your GitHub repositories, ensuring that your valuable code is safe and easily recoverable.
Use
Features
Overall:
- Asynchronous Resolution: Utilizes asynchronous processing for improved performance and responsiveness, allowing users to continue working while backups are being created.
- Simplicity and Ease of Use: Provides a straightforward and user-friendly method for creating backups from GitHub repositories.
List:
-
Backup Functionality:
- Repository Backup: Enables users to create local backups of GitHub repositories.
- Customizable Backup Options: Offers various command-line options to tailor the backup process, including specifying backup directories, , types of repositories and branches, token authentication, cleanup, backup retention period, and more.
- Automated Cleanup: Supports cleanup functionality to manage the disk space occupied by the backup files.
- Backup Retention: Allows users to specify the number of days to retain backups, automatically removing older backups based on the set retention period using the --daystokeepbackup argument.
-
Email Reporting:
- Email Notifications: Sends detailed email reports upon backup completion, providing status updates, backup job information, and relevant details.
- Email Customization: Offers different email layouts (--simpelreportlayout) to cater to varying preferences or requirements.
- Priority Configuration: Provides the option to set email priority (--priority) for the backup completion notification.
-
Logging:
- Job Logging: Stores logs for backup jobs in a designated folder (.\Log) for a defined period (default: 30 days) beside the GitHubBackupTool.exe executable.
The tools and code in it can as much of the same features as my Azure DevOps Backup tool, but with some changes to support the GitHub API. Some functions/data/API data is not the same, so some features/stat/status checks is not here at the movemt (we hope in the future).
Getting Started
Prerequisites
- .NET Core SDK installed on your system.
How to build
- Get Visual Studio 2022 (Community Edition is fine)
- Install ".NET desktop development" workload

- Remember to select: Install .NET 7.0 Runtime
- Build the solution in Visual Studio
Access token:
You can create a personal access token here: https://github.com/settings/tokens/new
Recommended scopes and use is for better security: https://github.com/settings/personal-access-tokens/new
- Repository access: All repositories
- Contents: Read-only
- Metadata: Read-only
Other scopes you can use:
- Comming as more features added if needed...
Access: Read access to repositories who needs backup and read access to user profile.
Installation
You can either clone this repository and build the project yourself.
Usage
GitHubBackupTool token-based <token> [<destination>] [<backuptype>] -mailto "mail-to@domain.com" -mailfrom "mail-from@domain.com" -mailserver "mailserver.domain.com" -mailport <port> -priority "high" -daystokeepbackup <days> -daystokeeplogfiles <days>
etc.:
GitHubBackupTool token-based <token> "D:\Backup\GitHub\" -allowner -mailto "mail-to@domain.com" -mailfrom "mail-from@domain.com" -mailserver "mailserver.domain.com" -mailport <port> -priority "high" -daystokeepbackup 50 -daystokeeplogfiles 180
Paramenters (NOT FINAL):
- token-based
- token.bin: Use an encrypted .bin file (based on hardware ID´s) with your GitHub personal access token in. (Remember to run -tokenfile <token.data> to create the file first beside the application .exe!)
- <token.data>: Replace this with your GitHub personal access token.
- "D:\Backup\GitHub": Specify the local directory where you want to store the GitHub repository backups.
- -allowner: Use this option to back up repositories owned by the token holder.
- -all: Use this option to back up all repositories the token have access to.
- -allnotforked: Use this option to back up repositories owned by the token holder and exclude forked repositories..
- -allowner: Use this option to back up repositories owned by the token holder.
- -allbranches: Use this option to back up all branches of repositories (default only DefaultBranch) by the token holder.
- -excludebranchdependabot: Use this option to exclude the branches with the name "dependabot" from the backup.
- -mailto "mail-to@domain.com": Provide an email address where backup completion notifications will be sent.
- -mailfrom "mail-from@domain.com": Specify the sender's email address for the notification emails.
- -mailserver "mailserver.domain.com": Define the SMTP server for sending email notifications.
- -mailport "25": Set the SMTP server port (default is 25).
- -priority "high": Specify the email priority for notifications (e.g., high, normal, low).
- -daystokeepbackup 180: Set the number of days to retain backup files before automatic removal (default is 30 days if not set).
- -daystokeeplogfiles 180: Set the number of days to retain log files before automatic removal (default is 30 days if not set).
- -backupmetadata: Backup metadata for each repository. If set, the code itself will be saved to the repo folder.
- -backupreleasedata: Backup release data for each repository. If set, the code itself will be saved to the repo folder.
- -gitbackupvalidation: Validate backup of repositories after backup is done. If set, the backup will be validated.
- ...
Automating Backups with Windows Task Scheduler
To run the backup automatically on a schedule, you can use Windows Task Scheduler. Follow these steps to configure it properly:
Task Scheduler Configuration
-
Open Task Scheduler and create a new task (not a basic task)
-
General Tab:
- Name:
GitHub Backup - Description:
Automated backup of GitHub repositories - Security options:
- ☑ Run whether user is logged on or not
- ☑ Run with highest privileges
- Configure for: Windows 10/Windows Server 2016 (or later)
- Name:
-
Triggers Tab:
- Click New...
- Set your schedule (e.g., Daily at 2:00 AM)
- Click OK
-
Actions Tab (MOST IMPORTANT):
- Click New...
- Action: Start a program
- Program/script:
"C:\Program Files (x86)\Michael Morten Sonne\GitHubBackupTool\GitHubBackupTool.exe" - Add arguments (optional):
token-based token.bin "C:\Backup\GitHub" -allowner -mailto "mail-to@domain.com" -mailfrom "mail-from@domain.com" -mailserver "mailserver.domain.com" -mailport "25" -priority
Related Skills
node-connect
352.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
