This repository contains a script and crontab entry that can be used to maintain copies of one or more repositories at GitHub.
This script was will run in any environment that can provide the following:
- A POSIX-compliant Bourne shell and standard command-line tools
- The cURL command-line interface
- The jq scripting language
Note that the install
target in the Makefile uses Linux-specific commands.
-
Create a dedicated user account for this program to use. Do not use a shared account, as the installation and removal process will clobber the user's crontab. (You may, of course, skip the
make install
step below and install the crontab yourself.) -
Become that user.
-
Clone this repository into a subdirectory of the user's home directory (
git clone https://github.com/markfeit/github-backup.git
). -
make install
. Note that this does not install any files outside the soure directory other than the crontab which runs it.
- Edit the
repos
file and add repositories as directed in the comments.
Repositories backed up by this program will appear in the archive
directory.
NOTE: This step is optional but strongly recommended. Without an access token, the program will be confined to GitHub's API rate limits. Each repository backed up generates eight API calls and any entry in the repository list that requires listing a user's repositories generates one.
-
Create a personal access token using your GitHub account. Give this token the minimum possible access (i.e., do not check any of the scope boxes.)
-
Create a file called
auth
in the directory where the sources were unpacked and add one line with your GitHub username and the token separated by a colon (e.g.,someuser:784eac6a358a602121ae98eedeadbeef1badcafe
). -
Set the permissions to user-only read (
chmod 400 auth
).
make uninstall
In the directory where the sources were unpacked.