🪶 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 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
<github_username>/<repo_name>
. If it already exists,git reset
it to ensure the exact same state as GitHub. - 📜 Write nice logs along the way.
To set up githubmirror on your own linux system:
- Ensure you have a recent version of the dependencies installed:
curl
,jq
, andgit
. - Clone this repository
- Request your Personal Access Token and store it in a plain file called
pat.txt
. chmod +x ./githubmirror.sh
- 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:# run gitmirror, pipe stdout and stderr to log file ./githubmirror.sh >> "logs/$(date +'%Y%m%d').log" 2>&1