Back up GitHub to Backblaze B2
Gitbackups backs up your GitHub repositories on a schedule into a bucket you own. This guide sets up Backblaze B2 for it in about five minutes. You end up with:
- A private bucketYours. The backups stay if you leave.
- A narrow keyOnly what backups need, on one bucket.
- A cleanup ruleClears the leftovers of a failed upload.
How Gitbackups connects to Backblaze B2
- Gitbackups talks to B2's S3-compatible API at https://s3.<region>.backblazeb2.com, with virtual-hosted addressing.
- It does not send the newer S3 request checksum headers, which B2's S3-compatible API does not accept.
- Each run uploads every repository as a git bundle file, at
<prefix><owner>/<repo>/<timestamp>-<id>.bundle. The files are yours: if you stop using Gitbackups, they stay where they are. - It never lists your bucket. Every file it writes is recorded on our side, so retention deletes only files Gitbackups wrote, and the newest backup of each repository is never deleted.
- On GitHub, Gitbackups is a GitHub App that asks for read access to repository contents and nothing more.
1. Create the bucket
- B2 Cloud Storage → Buckets → Create a Bucket.
- Name it and set it to Private.
- Copy the Endpoint B2 shows for the bucket. Your region is inside it (step 6).
2. Create a key for Gitbackups only
- B2 Cloud Storage → Application Keys → Add a New Application Key.
- Allow Access to Bucket(s): this bucket only.
- Access: Read and Write.
- File name prefix: your Gitbackups prefix, e.g.
gitbackups/. - Create New Key. Copy the
keyIDand theapplicationKeynow: B2 shows theapplicationKeyonly once.
3. Give it these four permissions, and no more
- B2 application keys don't take a policy document. The bucket restriction and the name prefix from step 2 keep the key inside the same folder the policy below describes.
- Read and Write on B2 is broader than these four actions: it can also list files under the prefix. Gitbackups never uses that.
- Leave “Allow List All Bucket Names” unticked.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GitbackupsArchives",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:AbortMultipartUpload"
],
"Resource": "arn:aws:s3:::BUCKET/gitbackups/*"
}
]
}4. Add the incomplete-upload cleanup rule
B2's web console can't set this rule: its lifecycle rules only hide and delete files. Set it once with Backblaze's b2 command-line tool, signed in with your account's master application key (b2 account authorize):
b2 bucket update --lifecycle-rule '{"fileNamePrefix": "", "daysFromUploadingToHiding": null, "daysFromHidingToDeleting": 1, "daysFromStartingToCancelingUnfinishedLargeFiles": 1}' BUCKET- The same rule keeps only the latest version of each file, which is what step 5 asks for.
- Skipping the command? At least pick Lifecycle Settings → “Keep only the last version of the file”. B2 keeps every version by default, so files Gitbackups deletes under your retention setting would still be stored and billed.
5. Versioning: leave it off
We recommend no versioning. Every run uploads a full archive, and the newest backup of every repository is never deleted, whatever your retention setting says. Versioning on top of full archives multiplies your storage bill by the number of runs you keep, for a second copy of data you already have.
6. Connect it in Gitbackups
In Gitbackups, choose Backblaze B2 as your storage. Here is each field in the form, and what Backblaze calls the value that goes in it.
- RegionNo label of its own
B2 has no Region field. It is the middle part of the bucket’s Endpoint:
s3.us-east-005.backblazeb2.com. Accounts live in different regions, so check yours. - Endpointoptional
EndpointOn the Buckets page, with your bucket. Paste it, or leave this blank and we build it from the region.
- BucketrequiredThe name only. Not a URL.No label of its own
The bucket’s name, as the Buckets page lists it.
- Path prefixoptionalUse one if anything else writes to this bucket.
File name prefixThe prefix you set on the key in step 2. Must match it exactly.
- Access key IDrequiredWe only ever show its last four characters.
keyIDShown when you create the key, and later on the Application Keys page.
- Secret access keyrequiredEncrypted on arrival. Never shown again.
applicationKeyShown once, right after you create the key. Lost it? Make a new key.
Then press Test connection. Gitbackups writes a small file under your prefix, reads it back, deletes it, and starts and aborts one empty multipart upload. If a step is refused, the screen tells you which permission is missing.
Start backing up
Sign up for Gitbackups, install the GitHub App, and point it at your Backblaze B2 bucket.
Setting up a different provider? AWS S3 · Cloudflare R2 · Wasabi · MinIO and other S3-compatible storage