gitdr documentation, gitdr.io. gitdr backs up GitHub and GitLab orgs to WORM-immutable object storage.
# What access gitdr asks for, and why
The exact scopes on each side, why backup never needs write, and why restore doesn't either.
A backup run holds two credentials, one for your git host and one for your bucket.
Neither can write to your code, your CI, or an existing backup. This page lists the
exact grants, so you can check every one against the
[code](https://github.com/gitdr-io/gitdr), which is open.
## The source credential (read-only)
The credential gitdr backs up with cannot write.
**GitHub.** gitdr authenticates as a GitHub App installation. The App needs four
repository permissions, every one of them read:
```
contents read-only the git data itself, plus releases
metadata read-only lists the org's repos, mandatory for any App
issues read-only issues, comments, labels, milestones
pull requests read-only pull requests and review comments
```
That is the whole set. A token minted from it can't push a commit, edit a workflow
file, or change a setting. Same grants on GitHub Enterprise Server.
**GitLab.** A project or group access token with two scopes, `read_api` and
`read_repository`. The first reads metadata over the API, the second pulls the git
data. Both are read scopes by GitLab's own definition. Same on self-managed GitLab.
Where the secrets go (env only, never in the YAML) is on the
[configuration page](/docs/configuration/).
## Why backup never needs write
A backup is a read. Cloning a mirror, listing repositories, and paging through issues
modify nothing, so a write scope would have no job to do. The binary couldn't use one
anyway. The Source interface has three methods, `ListRepos`, `CloneURL`, and
`FetchMetadata`, and no method mutates the upstream VCS. Hand gitdr a broader token
than it asked for and the extra grants sit unused, there is no code path that writes
to a source.
## Restore (credentials supplied at restore time)
Restore uses the same open-source binary with read access to the bucket. It downloads
the bundle, re-checks the checksum, and clones into a local directory. It never writes
to the destination.
Pushing the restored repo to a new home is a `git push --mirror` with a credential you
create at that moment, on whichever host you are restoring to. gitdr never holds it in
advance. So no standing write access to your code or CI exists anywhere in gitdr,
nothing sits in a vault between runs, and nothing is there to steal. The
[restore runbook](/docs/restore/) walks the whole path.
## The destination credential (create and put)
Backup needs create/put on the bucket. `verify` and `restore` need read. Nothing ever
needs delete, so don't grant it.
The code is built to match. The storage interface has no delete, remove, or overwrite
method anywhere in the codebase, enforced by lint in CI. Uploads are create-only, so a
key collision fails instead of replacing the object. Scope the credential the same way
and a leaked one can add objects to your bucket, and that is all it can do.
## Immutability is verified, never asserted
Before writing anything, gitdr asks the storage API whether the bucket is locked, the
S3 Object Lock configuration, the GCS retention policy, the Azure immutability policy.
A confirmed lock is recorded in the signed manifest. No confirmed lock means a loud
warning while the run proceeds, or a hard stop with `--require-worm`. gitdr never
reports protection it did not verify. [WORM buckets](/docs/worm/) shows how to set one
up per provider.
## Compare
The next time a backup tool asks you to authorize it, put its consent screen next to
this page.
---
# What is gitdr
Back up your whole git org to WORM-immutable object storage. One static binary, no telemetry.
gitdr backs up GitHub and GitLab organizations to object storage you own, and checks the
bucket is write-once (WORM) before it writes a thing. Deleted repo, popped account,
ransomware, and your history is still sitting somewhere they can't reach.
It's a single static Linux binary that runs as a one-shot job. No agents, no daemon, no
control plane, no phone-home. Point it at a source and a bucket, it does five things in
order and exits non-zero if any of them fail:
1. **Enumerate** every repo in the org over read-only source scopes.
2. **Verify WORM** on the destination. No lock means a loud warning, or a hard stop with
`--require-worm`.
3. **Bundle** each repo, full mirror clone plus LFS, SHA-256 streamed.
4. **Upload** create-only with a retain-until date. Nothing ever overwrites.
5. **Sign** an ed25519 manifest of the whole run.
`gitdr restore` gets your repos back. `gitdr verify` re-downloads everything and checks
the signature and every hash, so you find out backups are intact before you need them.
## Where to next
- [Quickstart](/docs/quickstart/), zero to a verified immutable backup in about 10 minutes.
- [Install and verify](/docs/install/), get it, and prove what you downloaded.
- [WORM buckets](/docs/worm/), make the destination immutable, per provider.
- [Restore runbook](/docs/restore/), how to get repos back when it matters.
- [Security](/docs/security/), the design stance and how to report a vulnerability.
- [Source on GitHub](https://github.com/gitdr-io/gitdr), AGPL-3.0, read it end to end.
## What it never does
The storage layer has no delete, remove, or overwrite method anywhere in the codebase.
Backups are append-only by construction. There is no telemetry of any kind. Credentials
come from env or your cloud's default credential chain, never from code, and are redacted
in every log line.
---
# Quickstart
Zero to a verified, immutable backup of one repo, in about 10 minutes.
Zero to a verified, immutable backup of one repo, in about 10 minutes.
gitdr is a single static Linux binary that runs as a one-shot job. On macOS, run the
container (`ghcr.io/gitdr-io/gitdr`).
## 1. Get the binary
```sh
# container
docker run --rm ghcr.io/gitdr-io/gitdr version
# or via Go (1.26+)
go install gitdr.io/gitdr/cmd/gitdr@latest
```
Static binaries with checksums and cosign signatures are also on the
[releases page](https://github.com/gitdr-io/gitdr/releases).
## 2. Make a WORM bucket
gitdr strongly recommends an immutable destination. It warns if the bucket isn't WORM,
and `--require-worm` makes it fail closed. Immutability is the whole point of a
ransomware-resistant backup, so set one up. Pick your provider.
**AWS S3**, Object Lock (only settable at creation):
```sh
aws s3api create-bucket --bucket my-worm-bucket --region us-east-1 \
--object-lock-enabled-for-bucket
aws s3api put-object-lock-configuration --bucket my-worm-bucket \
--object-lock-configuration \
'{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"COMPLIANCE","Days":30}}}'
```
**Google Cloud Storage**, locked retention policy (the lock is irreversible):
```sh
gcloud storage buckets create gs://my-worm-bucket --location=US \
--uniform-bucket-level-access --public-access-prevention --retention-period=30d
gcloud storage buckets update gs://my-worm-bucket --lock-retention-period
```
**Azure Blob**, create a storage account with version-level immutability plus blob
versioning, then a container ([Azure docs](https://learn.microsoft.com/azure/storage/blobs/immutable-version-level-worm-policies)).
Scope the credential gitdr uses to create/put only. It never needs delete.
## 3. Source credentials (read-only)
- GitHub. Create a GitHub App with read-only repo and metadata, install it, note the App
ID and Installation ID, and download the private key (PEM).
- GitLab. A project or group access token with `read_api` and `read_repository`.
## 4. Manifest signing key
Every run writes an ed25519-signed manifest. Make the keypair once.
```sh
openssl genpkey -algorithm ed25519 -out manifest-signing.pem
openssl pkey -in manifest-signing.pem -pubout -out manifest-public.pem
```
Keep `manifest-signing.pem` secret and off the runner if you can. `verify` only needs the
public key.
## 5. Config
Copy `config.example.yaml` to `config.yaml` and set the source and destination. A minimal
GitHub to S3 setup:
```yaml
source:
type: github
repo: "acme/api"
github: { appID: 123456, installationID: 7890123 }
destination:
type: s3
s3: { bucket: my-worm-bucket, region: us-east-1 }
retention: { mode: COMPLIANCE, days: 30 }
manifest:
publicKeyPath: ./manifest-public.pem
worm: { require: false } # warn on non-WORM and proceed. true means fail closed
```
## 6. Secrets (env only, never in the YAML)
```sh
export GITDR_GITHUB_APP_PRIVATE_KEY="$(cat github-app.pem)"
export GITDR_MANIFEST_SIGNING_KEY="$(cat manifest-signing.pem)"
export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... # or use an instance role
```
## 7. Preflight, then back up
```sh
gitdr doctor --config config.yaml # checks config, source auth, and the WORM lock
gitdr backup --config config.yaml # clone, bundle, sha256, immutable upload, signed manifest
```
`doctor` writes nothing. `backup` exits non-zero on any failure, so treat that as a failed
backup. The run prints the manifest key.
## 8. Verify
```sh
gitdr verify --config config.yaml --manifest
```
`signature valid: true, artifacts N/N ok` means the run is signed and intact. To prove a
real restore, follow the [restore runbook](/docs/restore/).
## 9. Schedule it
- Kubernetes. The [Helm chart](https://github.com/gitdr-io/gitdr/tree/main/charts/gitdr) (CronJob).
- VM. The [systemd timer or cron sample](https://github.com/gitdr-io/gitdr/tree/main/deploy).
- CI. Call `gitdr backup` from your pipeline.
## Optional: client-side encryption
To keep the storage provider from reading your data, set `encryption.enabled: true` and
give it a 32-byte key in `GITDR_ENCRYPTION_KEY` (64-char hex, base64, or raw). `verify`
stays key-free. `restore` needs the key.
---
# Install and verify
Get gitdr and prove the artifact you downloaded is the one that was built.
Every release ships signed. Don't skip the verify step, this is a backup tool, it runs
with credentials to your org.
## Container (works everywhere, including macOS)
```sh
docker run --rm ghcr.io/gitdr-io/gitdr:latest version
```
Wolfi base, non-root, read-only rootfs, no shell. Multi-arch (amd64, arm64). Pin by
digest in production, not by tag.
Verify the image signature (keyless, Sigstore). The pattern names the release workflow and a
version tag. One that matches only the repository also accepts certificates issued to the
repository's other workflows.
```sh
cosign verify ghcr.io/gitdr-io/gitdr:latest \
--certificate-identity-regexp '^https://github\.com/gitdr-io/gitdr/\.github/workflows/release\.yml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
```
## Binary
Static Linux binaries, amd64 and arm64, on the
[releases page](https://github.com/gitdr-io/gitdr/releases). Or via Go:
```sh
go install gitdr.io/gitdr/cmd/gitdr@latest
```
Verify a release download. The signature covers `checksums.txt`, which covers everything
else:
```sh
cosign verify-blob checksums.txt \
--certificate checksums.txt.pem --signature checksums.txt.sig \
--certificate-identity-regexp '^https://github\.com/gitdr-io/gitdr/\.github/workflows/release\.yml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
sha256sum -c checksums.txt --ignore-missing
```
## Helm chart
```sh
helm install gitdr oci://ghcr.io/gitdr-io/charts/gitdr
```
The chart is an OCI artifact and is cosign-signed the same way as the image.
## What ships with a release
Binaries, container image, Helm chart, SHA-256 checksums, cosign signatures and
certificates, an SBOM per archive, and SLSA build provenance. All built from a tag by CI,
no human in the loop.
---
# WORM buckets
Make the destination immutable, so ransomware and stolen credentials can't touch your backups.
WORM (write once, read many) means objects can't be deleted or overwritten until their
retention date, not even by you, not even by an attacker holding your keys. It's the
property that makes a backup survive the bad day it exists for.
## How gitdr treats it
Before writing anything, gitdr probes the destination's lock configuration. Then:
- **Lock confirmed.** It proceeds and records the observed immutability in the signed
manifest, so "was this backup on WORM storage" has a tamper-evident answer later.
- **No lock.** It warns loudly and proceeds. Configuring WORM is your job, but you'll
never be quietly unprotected.
- **`--require-worm`** (or `worm.require: true`). No confirmed lock means the run fails
closed. Use this once your bucket is set up.
Independent of all that, gitdr's storage layer has no delete or overwrite method, uploads
are create-only. WORM protects you from stolen credentials; create-only protects you from
gitdr itself.
## Set one up
**AWS S3**, Object Lock. Only settable at bucket creation:
```sh
aws s3api create-bucket --bucket my-worm-bucket --region us-east-1 \
--object-lock-enabled-for-bucket
aws s3api put-object-lock-configuration --bucket my-worm-bucket \
--object-lock-configuration \
'{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"COMPLIANCE","Days":30}}}'
```
COMPLIANCE mode is real WORM, nobody can shorten it. GOVERNANCE can be lifted with a
special permission, which an attacker with admin can also hold. Pick COMPLIANCE.
**Google Cloud Storage**, locked retention policy. The lock is irreversible:
```sh
gcloud storage buckets create gs://my-worm-bucket --location=US \
--uniform-bucket-level-access --public-access-prevention --retention-period=30d
gcloud storage buckets update gs://my-worm-bucket --lock-retention-period
```
**Azure Blob.** Storage account with version-level immutability plus blob versioning,
then a container with a time-based immutability policy
([Azure docs](https://learn.microsoft.com/azure/storage/blobs/immutable-version-level-worm-policies)).
## S3-compatible providers
"S3-compatible" is a spectrum, and Object Lock is one of the least universally
implemented parts. Set `destination.s3.endpoint` and usually `usePathStyle: true`.
| Provider | Object Lock | Notes |
|---|---|---|
| Wasabi | yes | compliance mode, Cohasset-assessed |
| Backblaze B2 | yes | enable at bucket creation, versioning required |
| MinIO / IDrive e2 | yes | create the bucket with object lock |
| Cloudflare R2 | no | bucket locks instead; gitdr cannot read them |
A provider that doesn't implement the Object Lock API can't be confirmed immutable, so
gitdr warns and proceeds, or fails closed under `--require-worm`.
Object Lock in this table means the provider offers it, not that the guarantee is the
same everywhere. On a store you run yourself the lock stops the S3 API, not root on the
host. MinIO and Ceph protect you from a stolen key, not from your own operators.
R2 is the near case. Its bucket locks do stop deletes and overwrites. An account
administrator can remove the rule, so the guarantee is not the one compliance mode gives.
R2 does not implement `GetObjectLockConfiguration` either, so gitdr reports `unknown`
rather than immutable.
## Credential scoping
The destination credential needs create/put and read. It never needs delete, so don't
grant it. A compromised runner then can't purge history even on a non-WORM bucket.
---
# Storage providers
Which object storage providers can give you WORM immutability, and which can't.
gitdr writes to any S3-compatible or major-cloud object storage. Immutability (WORM /
Object Lock) is a switch you flip on your own bucket. This table says which providers can
give you that switch, so you can pick one that clears a ransomware-resistant bar. Most
have a free tier.
| Provider | Integration | WORM / Object Lock¹ | Notes |
|---|---|:---:|---|
| Amazon S3 | S3-compatible | ✅ | Reference Object Lock (SEC 17a-4 assessed) |
| Google Cloud Storage | Native API | ✅ | Bucket Lock + Object Retention |
| Azure Blob Storage | Native API | ✅ | Immutability policies |
| Oracle Cloud (OCI) | S3-compatible | ✅ | Retention Rules |
| IBM Cloud Object Storage | S3-compatible | ✅ | Immutable Object Storage |
| Alibaba Cloud OSS | S3-compatible | ✅ | Retention / WORM |
| Backblaze B2 | S3-compatible | ✅ | Enable at bucket creation |
| Wasabi | S3-compatible | ✅ | Compliance mode, Cohasset-assessed |
| MinIO | S3-compatible | ✅ | Self-hosted, so your own root can bypass it |
| Ceph (RGW) | S3-compatible | ✅ | Self-hosted, so your own root can bypass it |
| IDrive e2 | S3-compatible | ✅ | |
| Tigris | S3-compatible | ✅ | Zero-egress + object lock |
| Impossible Cloud | S3-compatible | ✅ | EU |
| Scaleway | S3-compatible | ✅ | EU |
| Cloudian HyperStore | S3-compatible | ✅ | Enterprise / on-prem |
| NetApp StorageGRID | S3-compatible | ✅ | Enterprise / on-prem |
| Dell ECS | S3-compatible | ✅ | Enterprise / on-prem |
| Pure Storage FlashBlade | S3-compatible | ✅ | Enterprise / on-prem |
| Storj | S3-compatible | ⚠️ | Verify (object lock added recently) |
| OVHcloud | S3-compatible | ⚠️ | Verify current parity |
| Exoscale SOS | S3-compatible | ⚠️ | Ceph-backed; verify |
| Hetzner Object Storage | S3-compatible | 🔜 | Object Lock on roadmap |
| DigitalOcean Spaces | S3-compatible | ❌ | No object lock |
| Linode / Akamai | S3-compatible | ❌ | No object lock |
| Vultr | S3-compatible | ❌ | No object lock |
| Cloudflare R2 | S3-compatible | ❌ | Bucket locks, not Object Lock; gitdr cannot read them |
| Fastly Object Storage | S3-compatible | ❌ | No object lock |
| Garage / SeaweedFS | S3-compatible | ⚠️ | Open-source; limited, verify |
¹ WORM / Object Lock is a feature you enable on your own bucket. gitdr writes to any
supported destination regardless. This column says which providers offer a lock gitdr can read.
✅ supported · ⚠️ verify · 🔜 announced/roadmap · ❌ not available
A provider without the lock still works as a destination, gitdr warns loudly and
proceeds, or fails closed under `--require-worm`. Setup commands for the big three and
the S3-compatible quirks are in [WORM buckets](/docs/worm/).
*All product names, logos, and brands are property of their respective owners, used here
only for identification and interoperability. gitdr is independent and not affiliated
with, endorsed by, or sponsored by any listed provider.*
---
# Configuration
One YAML file, env overrides, and the rule that secrets never live in it.
One YAML file, passed with `--config` (or `GITDR_CONFIG`). Two rules:
1. **Secrets never go in the YAML.** They come from env only, and they're redacted in
every log line and error.
2. **Any field can be overridden via env**, `GITDR_` with underscores, e.g.
`GITDR_DESTINATION_S3_BUCKET=foo`. Handy in CI and Kubernetes.
## The file
```yaml
source:
type: github # github | gitlab
baseURL: "" # GHES /api/v3, or self-managed GitLab URL
repo: "octo-org/octo-repo" # single repo; empty = all accessible (filtered)
include: []
exclude: []
github:
appID: 0
installationID: 0
privateKeyPath: "" # or GITDR_GITHUB_APP_PRIVATE_KEY
destination:
type: s3 # s3 (AWS + S3-compatible) | gcs | azure
s3:
bucket: "my-worm-bucket"
region: "us-east-1"
endpoint: "" # empty = AWS; e.g. MinIO http://localhost:9000
usePathStyle: false # true for MinIO and most S3-compatible stores
gcs:
bucket: "" # bucket with a LOCKED retention policy
azure:
account: "" # uses DefaultAzureCredential
container: "" # container with an immutability policy
retention:
mode: COMPLIANCE # COMPLIANCE (true WORM) or GOVERNANCE, S3 only
days: 30
backup:
concurrency: 4 # repos backed up in parallel
resume: true # skip repos already backed up for the run date
lfs: true # fetch LFS objects (separate .lfs.tar artifact)
manifest:
signingKeyPath: "" # ed25519 private key (or GITDR_MANIFEST_SIGNING_KEY)
publicKeyPath: "" # ed25519 public key, needed by `gitdr verify`
metrics:
textfilePath: "" # node_exporter textfile .prom; empty = off
encryption:
enabled: false # client-side envelope encryption before upload
worm:
require: false # true = fail closed when immutability isn't confirmed
log:
level: info # debug|info|warn|error
format: json # json|text
```
## Secrets (env only)
| Env var | What |
|---|---|
| `GITDR_GITHUB_APP_PRIVATE_KEY` | GitHub App private key, PEM contents |
| `GITDR_GITLAB_TOKEN` | GitLab token, `read_api` + `read_repository` |
| `GITDR_MANIFEST_SIGNING_KEY` | ed25519 signing key, PEM contents |
| `GITDR_ENCRYPTION_KEY` | 32-byte AES-256 key (64-char hex, base64, or raw) |
| `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` | S3-compatible static keys, opt-in |
| `GITDR_DESTINATION_AZURE_CONNECTIONSTRING` | Azure connection string, only for emulators like Azurite. Real Azure uses `DefaultAzureCredential` |
Cloud credentials resolve through each SDK's default chain, so keyless workload identity
(IRSA, GKE Workload Identity, Azure Managed Identity) works with zero config and beats
static keys. Static keys are for S3-compatible providers that have nothing better.
---
# Run on a schedule
A backup that doesn't run on a schedule is a demo. CronJob, timer, or CI.
gitdr is a one-shot job on purpose. Scheduling belongs to whatever already runs your
jobs, so there's no daemon to babysit and no extra attack surface.
## Kubernetes (Helm CronJob)
```sh
helm install gitdr oci://ghcr.io/gitdr-io/charts/gitdr \
--set cronjob.schedule="0 2 * * *"
```
Secrets mount from Kubernetes Secrets into env, config from a ConfigMap. Prefer workload
identity (IRSA, GKE WI, Azure MI) on the pod's service account over static keys, then the
bucket credential never exists as a secret at all. See the
[chart values](https://github.com/gitdr-io/gitdr/tree/main/charts/gitdr) for the knobs.
## systemd timer
Samples in [deploy/systemd](https://github.com/gitdr-io/gitdr/tree/main/deploy/systemd).
The unit runs the binary as a locked-down service (dedicated user, env file for secrets),
the timer fires it nightly. `systemctl list-timers` shows the next run.
## Plain cron
Sample in [deploy/cron](https://github.com/gitdr-io/gitdr/tree/main/deploy/cron), a small
wrapper script that sources env and runs `gitdr backup`. Fine for a single box.
## CI pipeline
Call `gitdr backup` from a scheduled pipeline. GitHub Actions or GitLab CI schedules
work, and OIDC-based cloud auth means no long-lived bucket keys in CI secrets either.
## Alert on the one metric that matters
Set `metrics.textfilePath` and gitdr writes a `.prom` file for node_exporter's textfile
collector (atomic write, no push dependencies):
```
gitdr_last_successful_run
```
One Prometheus rule catches every failure mode, crashed job, wedged runner, revoked
credential, full disk:
```yaml
- alert: GitBackupStale
expr: time() - gitdr_last_successful_run > 86400 * 2
annotations:
summary: "git org backup hasn't succeeded in 2 days"
```
Alert on staleness, not on job failure. A job that silently never runs fires no failure
alert, but it can't fake freshness.
---
# Restore runbook
How to get your repos back from a gitdr backup, one repo or a whole org gone dark.
How to get your repos back from a gitdr backup, one repo or a whole org gone dark.
Practice this before you need it.
## Before you start
You need:
- The gitdr binary or container, same major version that wrote the backup.
- Read access to the destination bucket. A read-only credential is enough, restore never
writes to the destination.
- A config file pointing at that destination (`--config`), same as for backup.
- For `verify`, the manifest public key (`manifest.publicKeyPath` in config).
- If backups were encrypted, the encryption key in `GITDR_ENCRYPTION_KEY`. `verify`
doesn't need it, checksums cover the stored ciphertext.
## Object layout (what's in the bucket)
```
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.bundle git data (full mirror)
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.sha256 checksum of the bundle
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.meta.json metadata (audit/reference)
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.lfs.tar LFS objects (if any)
{host}/{org}/manifests/{timestamp}.manifest.json signed run-manifest (plus .sig)
```
So a backup of `github.com/acme/api` from 2026-06-01 lives under
`github.com/acme/api/2026-06-01/`.
## 1. Find the run
List the manifests and pick the run you want (use your cloud's CLI, like `aws s3 ls`,
`gcloud storage ls`, `az storage blob list`):
```sh
aws s3 ls s3://my-worm-bucket/github.com/acme/manifests/
```
## 2. Verify before you trust it
```sh
gitdr verify --config config.yaml \
--manifest github.com/acme/manifests/2026-06-01T02:00:00Z.manifest.json
```
This checks the ed25519 signature and re-downloads every artifact to confirm its SHA-256.
Exit code is non-zero on any signature or checksum mismatch. A clean `signature valid:
true, artifacts N/N ok` means the run is intact.
## 3. Restore a repository
```sh
gitdr restore --config config.yaml \
--host github.com \
--repo acme/api \
--date 2026-06-01 \
--out ./restore/api
```
gitdr downloads the bundle, re-checks its checksum, runs `git bundle verify`, and clones
it into `--out`. If encryption was used, set `GITDR_ENCRYPTION_KEY` first.
## 4. Sanity-check the restored repo
```sh
cd ./restore/api
git log --oneline -5
git fsck --full
git for-each-ref # all branches and tags present?
```
LFS objects (if any) are in the run's `.lfs.tar`. Unpack and `git lfs` them back per the
LFS docs for that repo.
## 5. Re-home to a new VCS
Point the restored repo at a fresh remote and push everything:
```sh
git remote add new https://new-host/acme/api.git
git push --mirror new
```
`--mirror` pushes all branches and tags. Re-create the org or project on the new host
first. gitdr restores git data, not org settings.
## Restoring a whole org
For a full DR event, drive the per-repo restore from the run-manifest. It lists every repo
and the date. Pull the manifest, iterate its `repos[]`, and run step 3 per repo, then step
5. Restore is independent per repo, so it parallelizes safely.
## What restores faithfully, and what doesn't
- Faithful: all git history, branches, tags, and LFS blobs. This is a true mirror.
- Audit and reference only: the `*.meta.json` (issues, PRs/MRs, comments, labels,
milestones, releases). No tool can replay these into a VCS with the original numbers,
authors, timestamps, or cross-references. Treat recovered metadata as a read-only record,
not a re-import.
## Troubleshooting
| Symptom | Cause / fix |
|---|---|
| `verify` reports a checksum failure | Object was altered or truncated at rest. Restore from an earlier good run, then investigate the bucket. |
| `restore` fails decrypting | Wrong or missing `GITDR_ENCRYPTION_KEY`. It must be the KEK used at backup time. |
| `git bundle verify` fails | Bundle is corrupt. Restore the same repo from a different run or date. |
| Access denied listing or getting | Restore credential lacks read on the bucket or prefix. |
| Can't find the date | Backups are dated by run. List the repo prefix to see available dates. |
---
# CLI reference
Four commands. Logs to stderr, results to stdout, non-zero exit on any failure.
```
gitdr [flags]
```
Four commands. Structured logs go to stderr, machine-readable results go to stdout, and
the exit code is the contract: **0 means the whole run succeeded, anything else means
treat it as a failed backup.** No partial success reported as success, ever.
## Common flags (every command)
| Flag | Default | What |
|---|---|---|
| `--config` | `$GITDR_CONFIG` | path to the config YAML |
| `--output` | `text` | result format on stdout, `text` or `json` |
| `--log-level` | from config | `debug` `info` `warn` `error` |
| `--log-format` | from config | `json` or `text` |
## backup
Clone, bundle, checksum, upload create-only, sign the run-manifest.
```sh
gitdr backup --config config.yaml [--repo owner/name] [--require-worm]
```
| Flag | What |
|---|---|
| `--repo` | back up one repo, overrides `source.repo` |
| `--require-worm` | fail closed if the destination isn't confirmed immutable |
Prints the manifest key on success. With `--output json`, stdout is the full signed
run-manifest.
## restore
Fetch a bundle, re-check its checksum, `git bundle verify`, clone it out.
```sh
gitdr restore --config config.yaml \
--repo acme/api --host github.com --date 2026-06-01 --out ./restore/api
```
| Flag | What |
|---|---|
| `--repo` | owner/name, required. `acme/platform/api` is the project `api` in the GitLab group `acme/platform` |
| `--manifest` | manifest object key, the `manifestKey` that `backup` printed. Replaces `--host` and `--date` |
| `--host` | source host, default `github.com` |
| `--date` | backup date, `YYYY-MM-DD`, required without `--manifest` |
| `--out` | output directory, required |
To restore exactly what a run wrote, name its manifest:
```sh
gitdr restore --config config.yaml \
--manifest --repo acme/api --out ./restore/api
```
The host and date then come from the manifest, so `--host` and `--date` are refused. It needs
`manifest.publicKeyPath`, and the manifest has to verify. Give it the key of a manifest a drill
passed, and it restores exactly what the drill restored.
Without `--manifest`, restore looks for a manifest that finished on the backup's date or the day
after. A run that took longer, or one an older version filed somewhere else, needs `--manifest`.
Needs only read access to the bucket. If backups were encrypted, set
`GITDR_ENCRYPTION_KEY`.
## verify
Check the manifest signature, then re-download every artifact and recompute its SHA-256.
```sh
gitdr verify --config config.yaml --manifest
```
| Flag | What |
|---|---|
| `--manifest` | manifest object key |
| `--drill` | drill report object key, instead of `--manifest` |
Give exactly one of the two. Needs `manifest.publicKeyPath` and read access. Doesn't need the
encryption key, checksums cover the stored ciphertext. Non-zero exit on any signature or
checksum mismatch.
```sh
gitdr verify --config config.yaml --drill
```
`--drill` checks a drill report's signature and prints what the document says: which manifest
it tested, whether that manifest's own signature was checked, and how many repositories came
back. It reads nothing out of the bucket beyond the report and its `.sig`, so it has no
artifact count, and it does not re-run the drill. It answers the question somebody holding a
printed evidence pack has, which is whether the document is authentic and what it claims.
The two forms refuse each other's documents. A drill report parses as a manifest with no
artifacts, so without that refusal `--manifest` on a drill report would print a valid signature
over nothing and exit zero.
## drill
Restore the backups and prove they carry the history they claim. `verify` re-reads the
artifacts and rechecks their checksums, which answers whether the copy is intact. `drill`
actually restores it and compares what came back. Two different claims, reported separately.
```sh
gitdr drill --config config.yaml --manifest --output json
```
| Flag | What |
|---|---|
| `--manifest` | manifest object key to drill; defaults to the most recent |
| `--host` | source host, e.g. `github.com`; needed when `--manifest` is not given |
| `--owner` | organisation; needed when `--manifest` is not given |
| `--sample` | restore at most this many repositories, in slug order; 0 means all |
| `--workdir` | where to restore; defaults to the system temp directory |
| `--no-report` | write nothing to the bucket; needs only read access and the public key |
Each repository is compared twice: against the bundle's own header, and against the ref map
the manifest signed when the copy was made. `sourceMatch` is absent, not false, when a copy
predates source-ref recording, because missing is not passing.
Refs a clone creates nothing for, `refs/merge-requests/*` and the like, are counted apart and
named rather than folded into the total.
Needs **both halves of the signing key**: `manifest.publicKeyPath` to verify the manifest it is
about to drill, and `manifest.signingKeyPath` to sign the report it writes. A drill of a manifest
whose signature nobody checked proves those artifacts restore rather than that gitdr wrote them,
and an unsigned report is a text file anybody can write. Also read access to the bucket and
enough disk in `--workdir` for the repositories it restores.
**It writes two objects to the destination**: the signed drill report, `{ts}.drill.json`, and its
detached signature, beside the manifest it drilled. They go through the same create-only path as
everything else, so the evidence is as immutable as the thing it proves — and, like every other
write, cannot be removed afterwards. This is the operator's command, not something to hand to a
reader who only needs to check a report; for that, see `verify --drill`, which needs the public
half only and writes nothing.
Exit 1 if any repository fails to restore or comes back at a different commit. **Exit 3** if
every repository restored and only storing the report failed: the restores passed and the
evidence was not filed, which is a different fact and gets a different code.
With `--no-report` the drill writes nothing. It signs and stores no report, so it needs only read
access and `manifest.publicKeyPath`, and it never loads the signing key, even when the config
names one. It still checks the manifest's signature, and the exit codes keep their meaning,
except that 3 cannot happen. An auditor can use it to re-run the restore from your bucket. The
report it prints is the only record, and nothing signs it.
## doctor
Preflight. Checks tooling (`git` on PATH), validates config, checks source auth, checks
the WORM lock. Writes nothing.
```sh
gitdr doctor --config config.yaml
```
Run it before the first backup and after any credential or bucket change.
## version
```sh
gitdr version
```
## Exit codes
| Code | Meaning |
|---|---|
| 0 | success |
| 1 | run failed (config, auth, network, any repo, any artifact) |
| 2 | usage error (bad flags, missing required flag) |
---
# Output contract
The manifest schema and the JSON output are a versioned, stable contract for your tooling.
The run-manifest schema and the `--output json` shapes are a stable, versioned public
contract. Build tooling on them. Changes get a new schema version, existing versions keep
verifying.
## Object layout (per run)
```
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.bundle git data, git bundle --all HEAD
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.meta.json metadata dump (gitdr.meta/v1)
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.sha256 sha256sum line for the bundle
{host}/{org}/{repo}/{YYYY-MM-DD}/{repo}.lfs.tar LFS objects, when present
{host}/{org}/manifests/{YYYYMMDDThhmmssZ}.manifest.json signed run-manifest
{host}/{org}/manifests/{YYYYMMDDThhmmssZ}.manifest.json.sig detached signature
```
Every object is written create-only, under object-lock retention when the bucket has it.
## Run-manifest (`gitdr.manifest/v2`)
```json
{
"schema": "gitdr.manifest/v2",
"runId": "20260613T120000Z-a1b2c3d4e5f6",
"tool": { "name": "gitdr", "version": "v0.1.0 (abc123def456)" },
"source": { "type": "github", "host": "github.com" },
"destination": {
"type": "s3", "bucket": "my-worm-bucket",
"wormMode": "COMPLIANCE", "wormImmutable": true,
"wormDetails": "Object Lock enabled; default retention COMPLIANCE"
},
"startedAt": "2026-06-13T12:00:00Z",
"finishedAt": "2026-06-13T12:03:00Z",
"status": "success",
"repos": [
{
"slug": "octo/hello",
"status": "success",
"artifacts": [
{ "kind": "bundle", "key": "github.com/octo/hello/2026-06-13/hello.bundle",
"size": 12345, "sha256": "…", "retainUntil": "2026-07-13T12:00:00Z" }
]
}
]
}
```
The parts that matter:
- `destination.wormImmutable` records the immutability **observed at write time**. The
manifest is signed, so this is a tamper-evident answer to "was this backup on WORM
storage".
- `status` (run and per-repo): `success`, `failed`, or `skipped` (resume found the repo
already backed up for the date). `repos[].error` appears only on `failed`.
- `artifacts[].kind`: `bundle`, `meta`, `sha256`, or `lfs`.
- Timestamps are RFC 3339 UTC. The signature is ed25519 over the exact stored bytes,
base64 in the `.sig` sidecar.
## `--output json` per command
| Command | stdout shape |
|---|---|
| `backup` | the run-manifest above |
| `restore` | `{ "bundleKey", "sha256", "outDir", "verified" }` |
| `verify` | `{ "manifestKey", "signatureValid", "artifactsChecked", "artifactsOk", "failures": [...] }` |
| `doctor` | `{ "ok", "checks": [ { "name", "ok", "detail" } ] }` |
Logs stay on stderr, so `gitdr backup --output json | jq .status` just works.
## Metadata dump (`gitdr.meta/v1`)
`{repo}.meta.json` holds raw upstream objects per section. GitHub: `repo`, `labels`,
`milestones`, `issues`, `comments`, `pullRequests`, `reviewComments`, `releases`. GitLab:
`project`, `labels`, `milestones`, `issues`, `mergeRequests`, `releases`, `notes`.
It's an audit record, not a restorable snapshot. No tool can replay issues or PRs into a
host with the original numbers, authors, and timestamps.
---
# Security
The design stance, what a compromise is worth, and how to report a vulnerability.
gitdr keeps immutable copies of people's source history, so its own security matters
more than most tools'. The stance is simple: fail closed, and make a compromise worth as
little as possible.
## Design stance
- **Read-only on the source.** GitHub App installation tokens or GitLab tokens with
read-only scopes. gitdr can't modify your org even if fully compromised.
- **Create-only on the destination.** The storage interface has no delete, remove, or
overwrite method anywhere in the codebase, enforced by lint in CI. A compromised
pipeline can't purge backups, and WORM retention enforces it regardless of gitdr.
- **No secrets at rest.** Credentials come from env or the cloud's default credential
chain. Nothing is baked into the image, and every log line redacts secret material.
- **Fail closed.** Any repo failure means a non-zero exit. Partial success is never
reported as success, so your alerting can trust the exit code.
- **No telemetry.** Zero analytics, zero phone-home, no update checks. The only network
connections are to your VCS and your bucket.
- **Signed everything.** Every artifact gets a SHA-256, every run gets an ed25519-signed
manifest, every release is cosign-signed with SLSA provenance.
The full analysis, trust boundaries, STRIDE tables, and the risk register live in
[THREAT-MODEL.md](https://github.com/gitdr-io/gitdr/blob/main/THREAT-MODEL.md).
## What's in scope for you to worry about
gitdr assumes the operator controls two things it can't:
- **Bucket immutability.** gitdr verifies and records it, but configuring WORM is your
call. See [WORM buckets](/docs/worm/).
- **Credential scoping.** Give the source credential read-only scopes and the destination
credential no delete. gitdr never needs more.
## Optional client-side encryption
Bucket server-side encryption is on by default at every major provider. If you also want
the provider unable to read your git data, enable envelope encryption
(`encryption.enabled: true`, key in `GITDR_ENCRYPTION_KEY`). AES-256-GCM per file,
streamed, so large bundles don't buffer. `verify` works without the key, `restore` needs
it. Losing the key means losing the backups, store it in a KMS or vault.
## Verifying releases
Every release is built from a tag by CI and signed keyless. Verify before you run,
commands are on the [install page](/docs/install/).
## Reporting a vulnerability
Don't open a public issue. Either channel works:
- Email **security@gitdr.io**, encrypted with the
[PGP key](/security-pgp-key.asc). Fingerprint
`FE90 9F5A 371E 83DB EAC9 1C3D C860 E582 7266 289A`.
- GitHub's private [security advisory](https://github.com/gitdr-io/gitdr/security/advisories/new)
on the repo.
Include the version (`gitdr version`), a redacted config, and what you observed.
Acknowledgment within 3 business days, coordinated disclosure, credit if you want it.
Pre-1.0, only the latest release gets fixes.