An open API service indexing awesome lists of open source software.

https://github.com/vankesteren/githubmirror

Shell script to back up all GitHub repositories you own
https://github.com/vankesteren/githubmirror

backup github linux mirror nas shell-script synology-nas

Last synced: 7 months ago
JSON representation

Shell script to back up all GitHub repositories you own

Awesome Lists containing this project

README

          

# GitHub mirror

![GitHub License](https://img.shields.io/github/license/vankesteren/githubmirror) ![GitHub file size in bytes](https://img.shields.io/github/size/vankesteren/githubmirror/githubmirror.sh)

ðŸŠķ A lightweight, legible bash script to keep a copy of all your GitHub repos. The `githubmirror.sh` script does the following:

- 🔏 Read your [Personal Access Token](https://github.com/settings/tokens?type=beta) from a local file.
- 🔗 Connect to the GitHub API to find all the repos of which you are an owner (even private ones!).
- 🗃ïļ Clone repos into the folder `/`. If it already exists, `git reset` it to ensure the exact same state as GitHub.
- 📜 Write nice logs along the way.

## Installation

To set up githubmirror on your own linux system:

1. Ensure you have a recent version of the dependencies installed: [`curl`](https://curl.se), [`jq`](https://jqlang.github.io/jq/), and [`git`](https://git-scm.com/).
2. Clone this repository
3. Request your [Personal Access Token](https://github.com/settings/tokens?type=beta) and store it in a plain file called `pat.txt`.
3. `chmod +x ./githubmirror.sh`
4. Set up a weekly recurring task (via `cron` or via your OS's task scheduler) to run the script. To run the script while keeping logs, I recommend the following:
```bash
# run gitmirror, pipe stdout and stderr to log file
./githubmirror.sh >> "logs/$(date +'%Y%m%d').log" 2>&1
```