Skip to content
Linkest-FDTPublic

About

Self-hosted GitHub organization disaster-recovery mirror: daily code + metadata backup, versioned releases, public status page. MIT.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

Kernel — GitHub Organization Disaster Backup

Copyright (c) CrCLARE Studio Maintained by Linkest Foundation SPDX-License-Identifier: MIT

Licensed under the MIT License. See the LICENSE file at the repository root for the full permission notice and disclaimer.

Kernel is a self-hosted disaster-recovery mirror for GitHub organizations. It runs a daily backup Action that enumerates every repository in a source organization (public + private), snapshots code and metadata, publishes versioned Releases, and keeps a public status page. If the primary organization fails, snapshots can be recovered by request.

Kernel does not promise "never lose data." It only promises: on the day the house falls, the stone under your pillow opens, verifies, and can be poured back. See RESTORE.md for the drill.

Production instance: https://kernel.linkest.org — the live status page running on Linkest Foundation's own organization. Use it as a working reference for what this deployment looks like.

This release ships five files at the repository root:

File Purpose
backup.yml The daily backup GitHub Action (place it at .github/workflows/backup.yml in your chosen repo)
index.html The public, read-only backup status page (English only)
RESTORE.md Recovery runbook: verify, unpack, re-push full / shallow snapshots, re-import metadata, reconcile the manifest
LICENSE MIT license full text
README.md This guide

How it works

  1. Daily run — at 02:00 UTC every day (or on manual dispatch), the workflow enumerates every repository in the source organization.
  2. Snapshot — for each repo it backs up code plus metadata: issues, pull requests, discussions, releases and assets, wiki, labels, milestones, attachments, repository settings, branch protection, rulesets, environments, webhooks, deploy keys, collaborators, teams, Actions permissions, and org-level settings.
  3. Git strategy (automatic per repo) —
    • Full-history mirror clone when history size ≤ GIT_FULL_MAX_MB (default 500 MB).
    • If history exceeds the threshold, fall back to a --depth 1 shallow snapshot (current code only, no history).
    • Metadata (issues / PRs / discussions / releases / wiki) is always backed up in full regardless of git mode. Each repo entry in the internal manifest carries git_mode: "full" | "shallow".
  4. Publish — one GitHub Release per run (tag v<UTC timestamp>) with one .tar.gz per repo; a private internal manifest.json to the private Backup repo; a public summary manifest.json to the public Website repo.
  5. Retention — keep the latest N releases, delete older ones. The public summary manifest tracks only the latest run (the status page needs no history); the private internal manifest is archived per run inside its matching Release asset, so reconciliation against an older snapshot still has a ledger. Do not prune the private manifest history when pruning Releases.

Part 1 — Set up the backup Action

backup.yml ships at the repository root of this distribution. This distribution repo does not itself run the backup — you place the file yourself where Actions can run it.

Repository layout expected (recommended)

Create a dedicated backup organization with three repos, split by purpose:

BACKUP_ORG/
  ├── Automation  (public)  — runs the backup workflow; holds backup.yml + secrets
  ├── Website     (public)  — public summary manifest.json (status page)
  └── Backup      (private) — internal manifest.json + Release assets
  • Automation (public) — home for backup.yml and the Action secrets. Run the workflow here.
  • Website (public) — serves the public summary manifest read by the status page.
  • Backup (private) — stores the internal manifest and Release assets.

If you do not want a separate Automation repo, put backup.yml in the public Website repo instead. Do not run the workflow from the private Backup repo: free Actions minutes are metered more tightly for private repos and concurrency is limited, and outbound calls to BACKUP_ORG may also hit org-level Actions policies or self-hosted runner restrictions. The workflow repo must therefore be public; it holds only the workflow file, never plaintext secrets (those live in encrypted repo secrets).

Where to put backup.yml

GitHub runs a workflow only from .github/workflows/. So in whichever repo you choose (Automation, or Website if you skip Automation), place the file at:

.github/workflows/backup.yml

The file content is unchanged; only its location inside your chosen repo must be .github/workflows/backup.yml.

Required secrets

Settings → Secrets and variables → Actions → Repository secrets:

Secret Required Description
BACKUP_TOKEN yes A personal access token. Either a classic PAT (ghp_...) or a fine-grained PAT (github_pat_...); do not mix the two styles. The preflight only checks that the token still authenticates (401 = expired / revoked / malformed); it does not validate scope. See permissions below.
BACKUP_TARGET_ORG yes The source organization to enumerate and back up. Example: MyOrg.
BACKUP_ORG yes The destination organization holding the Backup and Website repos. Keep it isolated from the source org so a source-org outage does not take the mirror down with it. Example: MyOrg-Backup.
BACKUP_PRIVATE_REPO yes Private repo inside BACKUP_ORG storing the internal manifest and Release assets. Example: Backup.
BACKUP_PUBLIC_REPO yes Public repo inside BACKUP_ORG storing the public summary manifest (served by the status page). Example: Website.

BACKUP_TOKEN permissions

The token serves two roles: read everything from the source organization, and write to the destination organization. Create it with the minimum scope that covers both.

Read — source organization (BACKUP_TARGET_ORG):

  • repo (full) — clone every public and private repository, read contents, issues, pull requests, comments, reviews, commits, labels, milestones, releases and assets, wiki, and attachments.
  • read:org — enumerate the organization, list teams, org webhooks, org rulesets, and org-level Actions variables/secrets metadata.
  • read:enterprise — only if the source org sits under an enterprise and you want enterprise-level settings mirrored; otherwise optional.

Write — destination organization (BACKUP_ORG):

  • repo (full) — push the internal and public manifest.json, create and delete Releases, and upload Release assets (the .tar.gz snapshots).
  • workflow — only if the destination repos themselves carry Actions workflows that the token must touch; not required for the mirror itself.

Repo-level extras the workflow reads (non-fatal on 403):

  • Branch protection, repository rulesets, environments and their secrets/variables, deploy keys (public half only), collaborators, teams, webhooks, and Actions permissions. Most of these need a token with organization owner/admin scope; without it the endpoint returns 403 and the workflow skips that item rather than failing.

Classic PAT: tick repo, read:org (and read:enterprise if needed). Fine-grained PAT: resource owner = source org for read, destination org for write; repository permissions — Contents: Read, Issues: Read, Pull requests: Read, Discussions: Read, Releases: Read + Write, Metadata: Read, Workflows: Read (source) / Write (destination); organization permissions — Members: Read, Webhooks: Read, Administration: Read (optional, for org settings). The token does not need to read secret plaintext values — the platform never exposes those, and Kernel does not request them.

Optional secrets

Secret Default Description
BACKUP_RETENTION 3 Positive integer: maximum number of Releases to keep. Unset, blank, or non-numeric falls back to 3.
BACKUP_COMMIT_NAME kernel-bot Git author name used when pushing manifests.
BACKUP_COMMIT_EMAIL kernel-bot@example.com Git author email used when pushing manifests.

Optional repository variable

Settings → Secrets and variables → Actions → Repository variables:

Variable Default Description
GIT_FULL_MAX_MB 500 Full-history size ceiling in MB. Repos whose mirror clone exceeds this are downgraded to --depth 1 shallow snapshots.

Quick start

  1. Create BACKUP_ORG with three repos: Automation (public, runs the workflow), Website (public, serves the status page + manifest), and Backup (private, holds internal manifest + Release assets). If you prefer to skip Automation, use Website as the workflow repo instead.
  2. Drop backup.yml at .github/workflows/backup.yml in your workflow repo (Automation, or Website if you skipped Automation).
  3. Add the required secrets above under Settings → Secrets and variables → Actions → Repository secrets of that workflow repo.
  4. Trigger the workflow manually (workflow_dispatch) to verify; the daily 02:00 UTC schedule then takes over.

Do not run the workflow from the private Backup repo: free Actions minutes are metered more tightly for private repos and concurrency is limited, and outbound calls to BACKUP_ORG may also hit org-level Actions policies or self-hosted runner restrictions.

Org admin endpoints (org webhooks, teams, rulesets, org secrets/variables) need owner/admin scope and will 403-skip without it (non-fatal).


Part 2 — Set up the status page

index.html is a static, English-only, read-only overview. It fetches the public summary manifest.json from the same origin and renders latest backup time, repo count, frequency, retention, and the snapshot timeline. It has no API, no login, and no download endpoint.

Configure SITE_CONFIG

Edit the SITE_CONFIG block at the top of the <script>:

const SITE_CONFIG = {
  siteName: "Projects Backup",            // top bar + browser tab title
  logoUrl: "https://breadfish.linkest.org/Kernel.svg",  // hosted mark, CC BY-NC-SA 4.0, no trademark license — comply or replace
  recoveryEmail: "admin@example.com",     // "Request Recovery" mailto: target
  manifestUrl: "/manifest.json",          // public summary manifest path (same origin)
  copyrightHolder: "CrCLARE Studio",       // footer copyright holder
  homeUrl: ""                             // footer home link ("" to omit)
};
Field Meaning
siteName Shown in the top bar and browser tab.
logoUrl Logo image URL used in the top bar and hero. Defaults to the hosted BreadFish Kernel mark (https://breadfish.linkest.org/Kernel.svg), provided for you under CC BY-NC-SA 4.0 with no trademark license — comply (non-commercial, share-alike, attribution) or replace with your own logo; set "" for a text-only wordmark.
recoveryEmail Recovery mailbox; the "Request Recovery" button mailto: target.
manifestUrl Public summary manifest path served from this origin (read-only).
copyrightHolder Copyright holder printed in the footer.
homeUrl Footer home link; leave "" to omit.

The "Powered By Kernel" credit and its link to https://github.com/Linkest-FDT/Kernel are fixed and must not be changed. Remove the whole credit block only if you remove it entirely.

Recovery flow

Recovery is granted by request only. The visitor emails the address in recoveryEmail; after an administrator verifies identity and authorization, the requested backup file is provided directly (email attachment for smaller files, cloud storage for larger ones). The public page never serves downloads itself.


Not covered by backup · keep these yourself

The platform does not expose these values, or shows them only once at creation. The mirror cannot store them — keep your own secure copy:

  • Secret plaintext values — repository, organization, and environment Secrets are only readable by name; their actual values are never returned by the API.
  • Webhook signing secrets — the secret used to sign incoming webhook payloads is shown once at creation and cannot be read back.
  • Deploy key private keys — only the public key is backed up; the private key half of a deploy key never leaves your account.
  • OAuth App / GitHub App credentials — client secrets, app private keys, and webhook secrets are displayed only once when created and cannot be re-read.
  • Billing, usage, and paid quota — payment plans, usage limits, and billing records are not part of the repository mirror.
  • Already deleted data — deleted issues, PRs, comments, and release assets are gone from the source and cannot be recovered from here.
  • Enterprise SAML SSO / SCIM — enterprise identity configuration is outside the repository backup.

If any item above is lost, the disaster mirror cannot restore it. Rotate or reissue through the provider before they expire, and store copies in your own password manager or sealed vault.

Recovery drill

A snapshot that has never been restored is a hypothesis, not a backup. Run a full restore drill at least once a month following RESTORE.md: verify a snapshot's checksum, unpack it, re-push to a throwaway org, re-import metadata, and reconcile the repo count against the private manifest. Record the result (date, snapshot tag, repos restored, failures) in a restore-log.json and surface the last drill date on the status page. A mirror that has never been drilled should not be advertised as recoverable.


License

MIT. Full text is in the LICENSE file at the repository root. The short copyright header (CrCLARE Studio / Maintained by Linkest Foundation / SPDX-License-Identifier: MIT) appears inside each source file.

About

Self-hosted GitHub organization disaster-recovery mirror: daily code + metadata backup, versioned releases, public status page. MIT.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages