vankesteren / githubmirror

Shell script to back up all GitHub repositories you own

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub mirror

GitHub License GitHub file size in bytes

๐Ÿชถ 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.

Installation

To set up githubmirror on your own linux system:

  1. Ensure you have a recent version of the dependencies installed: curl, jq, and git.
  2. Clone this repository
  3. Request your Personal Access Token and store it in a plain file called pat.txt.
  4. chmod +x ./githubmirror.sh
  5. 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

About

Shell script to back up all GitHub repositories you own

License:MIT License


Languages

Language:Shell 100.0%