Skip to main content

Install the worker

The worker is one program, github-backup-worker. This site hands it out for Linux and macOS (x86-64 and ARM) and for 64-bit Windows. It needs git on the machine to clone your repositories.

The worker backs up only while the machine is linked to your account and the account has a paid plan. Before each backup it gets a run pass from this service and checks it, so a worker from this site works only with this service. See Security and privacy.

Install​

Linux and macOS​

curl -fsSL https://holdfast-docs.mishrashardendu22.dev/install.sh | sh

Windows​

In PowerShell:

irm https://holdfast-docs.mishrashardendu22.dev/install.ps1 | iex

On an ARM PC it installs the x64 build, which Windows runs through its built-in emulation. Open a new terminal afterwards so the new PATH applies.

What the installer does​

  1. Downloads the build for your system and processor over HTTPS, and checks it against the site's SHA-256 checksums. On a mismatch it stops and installs nothing.
  2. Installs the program: ~/.local/bin/github-backup-worker on Linux and macOS, %LOCALAPPDATA%\github-backup\bin\github-backup-worker.exe on Windows (added to your user PATH). No administrator rights are needed.
  3. Creates your settings file, worker.env (see Settings and commands). An existing one is kept.
  4. Adds the hourly job, which backs up at your account's weekly slot once the machine is linked.

Then it prints the next steps, in this order: link the machine, give it access to GitHub and choose where backups go.

Options​

Linux and macOSWindowsEffect
sh -s -- --systemInstall the program into /usr/local/bin for every user; sudo asks for your password.
sh -s -- --no-schedule$env:GHB_NO_SCHEDULE = '1' before the commandInstall the program and settings, without the hourly job.
sh -s -- --uninstall-Uninstall (see Remove the worker)Remove the hourly job.
sh -s -- --helpPrint every option.

On Linux and macOS the options go after the pipe, for example curl -fsSL https://holdfast-docs.mishrashardendu22.dev/install.sh | sh -s -- --no-schedule. To read the script before you run it, download it first: curl -fsSLO https://holdfast-docs.mishrashardendu22.dev/install.sh, then sh install.sh.

A server on your local network​

When the service runs on a machine in your local network, its address is a number such as https://192.168.1.20:8445, and its certificate is signed by that machine's own certificate authority, which your computer does not know. Get the authority's certificate from the person who runs the server (sudo ghb ca > ghb-ca.crt on the server prints it) and save it as ghb-ca.crt.

On Linux and macOS, name the file in the install command, in the folder that holds it:

curl -fsSL --cacert ghb-ca.crt https://192.168.1.20:8445/install.sh | GHB_CA_CERT="$PWD/ghb-ca.crt" sh

On Windows, import the certificate for your user once, then install as usual:

Import-Certificate -FilePath .\ghb-ca.crt -CertStoreLocation Cert:\CurrentUser\Root
irm https://192.168.1.20:8445/install.ps1 | iex

The worker itself needs the same certificate in the system's store before it links; the person who runs the server has the commands. The worker trusts only that store: it ignores SSL_CERT_FILE and SSL_CERT_DIR, so a storage server with a certificate from its own authority needs that authority in the store as well. It also connects to the service directly, never through a proxy named in HTTPS_PROXY or HTTP_PROXY.

Without the certificate​

You can turn the certificate check off instead:

curl -fsSLk https://192.168.1.20:8445/install.sh | GHB_INSECURE=1 sh
$env:GHB_INSECURE = '1'; irm https://192.168.1.20:8445/install.ps1 -SkipCertificateCheck | iex

-SkipCertificateCheck needs PowerShell 7. With the check off, nothing proves that the script, the program and its checksums come from your server: someone on the same network can replace all three, and the checksum then only catches a damaged download. Use these commands only on a network you trust, and never with an address on the internet.

Update​

Run the same install command again. It replaces the program and keeps your settings, logins and link, and rewrites the hourly job. Run it again also when Troubleshooting tells you to.

Settings and commands​

The installer puts the worker's files in these places:

LinuxmacOSWindows
Settings~/.config/github-backup/worker.env~/Library/Application Support/github-backup/worker.env%APPDATA%\github-backup\worker.env
Records and temporary clones~/.local/state/github-backup/~/Library/Application Support/github-backup/state/%LOCALAPPDATA%\github-backup\state\
Logins and link~/.config/github-backup/~/Library/Application Support/github-backup/%APPDATA%\github-backup\

Put the settings from Choose where backups go into worker.env. The file is readable by your user only.

The hourly job reads worker.env by itself. When you run the worker's commands yourself (a backup now, verify), point ENV_FILE at the same file first, once per terminal:

export ENV_FILE="$HOME/.config/github-backup/worker.env" # Linux
export ENV_FILE="$HOME/Library/Application Support/github-backup/worker.env" # macOS
$env:ENV_FILE = "$env:APPDATA\github-backup\worker.env"

link, login, auth status and version do not need it.

Give the worker access to GitHub​

The worker needs to list and clone your repositories. Pick one of these.

The GitHub CLI's login (simplest)​

gh auth login
github-backup-worker login github --from-gh

This copies the GitHub CLI's token into your system keychain. Then name the accounts to back up in worker.env:

PROJECT_ACCOUNT=your-github-login # your own repositories
ORG_ACCOUNT=your-org,another-org # organizations, comma-separated

The worker backs up the repositories of these accounts and every private repository the login can see.

Your own GitHub App​

A GitHub App gives read-only access to exactly the repositories you choose, private ones included.

github-backup-worker github-app create # the app belongs to your user account
github-backup-worker github-app create --org your-org # or to an organization you administer

GitHub opens in the browser and asks you to confirm the app. Then, on GitHub:

  1. Open the app's settings page (the command prints its address), tick Enable Device Flow and save.
  2. Install the app on every account to back up, at https://github.com/apps/<app name>/installations/new, and choose the repositories.

Then log in:

github-backup-worker login github

The command prints a code and opens https://github.com/login/device. Enter the code there. With an app login the worker backs up the repositories granted to the app, and needs no PROJECT_ACCOUNT or ORG_ACCOUNT.

The app only asks for Contents: read and Metadata: read. Its login is renewed automatically; a machine that has not run a backup for about six months needs github-backup-worker login github again.

Machines that back up while you are logged out​

On Linux the keychain is still locked after a reboot until you log in, so the hourly job cannot read the login or the link from it. Store both in a file instead (readable by your user only): github-backup-worker login github --from-gh --store file, and add --store file to the link command.

The hourly job​

Every hour the job checks whether the machine is linked. Until it is, the job does nothing. Once it is linked, the job runs github-backup-worker run --scheduled, which backs up when your account's weekly slot has come, runs the backups you queued, and otherwise does nothing. See Schedules and runs.

SystemThe jobIts log
Linux with systemdUser timer github-backup.timer, hourly at a minute fixed for the machine. A check missed while the machine was off runs at the next boot. The installer turns on lingering so the timer also runs while you are logged out; when that is not allowed it prints sudo loginctl enable-linger $USER for you to run.journalctl --user -u github-backup
Linux without systemd, for example WSLA crontab line marked # github-backup-worker:managed. Your own lines are kept.~/.local/state/github-backup/worker.log
macOSLaunchAgent com.github-backup.worker, hourly and at login. It runs while you are logged in; a check missed during sleep runs after the Mac wakes.~/Library/Logs/github-backup/worker.log
WindowsTask \github-backup\github-backup in Task Scheduler, hourly for your user while you are logged on. A missed check runs as soon as possible.%LOCALAPPDATA%\github-backup\state\worker.log

Download by hand​

SystemFile
Linux, x86-64github-backup-worker_linux_amd64.tar.gz
Linux, ARM64github-backup-worker_linux_arm64.tar.gz
macOS, Apple silicongithub-backup-worker_darwin_arm64.tar.gz
macOS, Intelgithub-backup-worker_darwin_amd64.tar.gz
Windows, x64github-backup-worker_windows_amd64.zip
ChecksumsSHA256SUMS

Check the download against SHA256SUMS before you run it. In the folder that holds both files:

grep linux_amd64.tar.gz SHA256SUMS | sha256sum -c - # Linux
grep darwin_arm64.tar.gz SHA256SUMS | shasum -a 256 -c - # macOS

Each prints OK for a good file. In PowerShell, compare the hash with the line for the zip file in SHA256SUMS:

(Get-FileHash .\github-backup-worker_windows_amd64.zip -Algorithm SHA256).Hash.ToLower()

Then unpack it and move github-backup-worker (or github-backup-worker.exe) to a folder on your PATH. On macOS, a file downloaded with a browser is quarantined: run xattr -d com.apple.quarantine github-backup-worker once before you start it. A program installed by hand gets no settings file and no hourly job; the installer sets both up. Like the installed one, it backs up only once the machine is linked, and only with this service.

Check the installation​

github-backup-worker version
github-backup-worker auth status

version ends in (customer build). auth status lists the stored logins (never a secret) and whether the machine can back up: Runs: not linked until you link the machine, then Runs: linked to ....

Remove the worker​

Remove the hourly job:

curl -fsSL https://holdfast-docs.mishrashardendu22.dev/install.sh | sh -s -- --uninstall # Linux and macOS
curl -fsSL https://holdfast-docs.mishrashardendu22.dev/install.sh | sh -s -- --uninstall --remove-program # also delete the program
& ([scriptblock]::Create((irm https://holdfast-docs.mishrashardendu22.dev/install.ps1))) -Uninstall # Windows
& ([scriptblock]::Create((irm https://holdfast-docs.mishrashardendu22.dev/install.ps1))) -Uninstall -RemoveProgram # also delete the program

Your settings, records and logins stay. github-backup-worker logout all removes the stored logins and github-backup-worker unlink the link; when you retire the machine, revoke it under Settings > Agents as well.