Schedule icon
Commands icon
Docker icon
Upload icon
Download icon
If icon
Log icon
Fail icon

Back up GitHub repository history to S3 with a tested Git bundle

Back up GitHub refs to S3 with a Git bundle. Download, restore, and compare refs before publishing a verified manifest.

Categories
CloudInfrastructure

Keep an independent copy of a public GitHub repository's fetched refs and reachable objects in S3. Upload success alone cannot prove recoverability. The flow restores the uploaded Git bundle and verifies its contents before publishing a completion manifest.

How it works

  1. Clone the public repository with --mirror and inventory every fetched ref name and object ID.
  2. Create and verify a Git bundle. Record its SHA-256, size, and ref count.
  3. Upload the bundle to an execution-specific S3 prefix and download it.
  4. Verify the downloaded checksum, restore it into a new bare repository, and compare every restored ref name and object ID with the inventory.
  5. Publish the ref inventory and manifest only after verification passes. If verification fails, the flow fails and publishes no manifest.

What you get

  • An S3 backup.bundle containing fetched Git history and reachable objects.
  • An expected-refs.txt inventory of backed-up ref names and object IDs.
  • A manifest.json with repository, execution ID, SHA-256, byte size, and ref count. Its presence indicates the read-back verification succeeded.
  • A verification.json output recording PASS or BLOCK and a reason.
  • Outputs at outputs.make_bundle, outputs.verify_roundtrip, and outputs.commit_manifest for inspection and downstream automation.

Who it's for

  • Platform engineers keeping independent, recoverable Git history copies.
  • Teams checking backup integrity before trusting an S3 archive.
  • Operators who need a repeatable recovery drill for public repositories.

Why orchestrate this with Kestra

  • Kestra sequences clone, upload, download, restore, and validation tasks.
  • Each execution uses an isolated S3 prefix, making backups auditable.
  • A failed verification blocks manifest publication, instead of marking an unusable upload as completed.
  • Enable the included disabled schedule after a successful restore drill.

Prerequisites

  • A Kestra worker with Docker and the Scripts Shell and AWS S3 plugins.
  • Network access to github.com and Alpine package repositories.
  • An existing S3 bucket in the specified Region. Grant the worker s3:PutObject and s3:GetObject on the git-mirrors prefix.
  • Sufficient worker disk space for clone, bundle, and restored copy.
  • Read-only Git access is sufficient; no source repository is modified.

Secrets

  • GIT_MIRROR_S3_BUCKET: S3 bucket name used by scheduled executions. Manual executions can pass the bucket input directly.
  • Use your Kestra worker's IAM role for S3 authorization; the flow does not require AWS access keys in inputs or scripts.

Quick start

  1. Enter a public GitHub owner, repository, bucket, and Region.
  2. Run manually, then inspect verification.json for a PASS verdict.
  3. Confirm the execution-specific S3 prefix has backup.bundle, expected-refs.txt, and manifest.json.
  4. Download backup.bundle and run: git clone --mirror backup.bundle restored.git
  5. Compare refs with expected-refs.txt and perform a recovery drill. Set GIT_MIRROR_S3_BUCKET and enable the schedule only afterward.

How to extend

  • Add alerts for failed executions and missing expected manifests.
  • Apply S3 encryption, least-privilege access, versioning, and retention.
  • Add lifecycle rules and periodic restore drills for older bundles.
  • A bundle does not contain Git LFS objects, issues, comments, releases, wikis, or refs the clone endpoint does not advertise. Back these up separately if needed.
  • A fetched clone is a snapshot, not a transactionally consistent GitHub export. The size limit is checked after bundle creation.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.