Back up GitHub to AWS S3
Gitbackups backs up your GitHub repositories on a schedule into a bucket you own. This guide sets up AWS S3 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 AWS S3
- Gitbackups talks to the standard S3 API at https://s3.<region>.amazonaws.com, with virtual-hosted addressing.
- 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
- S3 console → General purpose buckets → Create bucket.
- Note the region you create it in. You will need it in step 6.
- Block all public access stays on. Nothing else needs changing.
2. Create a key for Gitbackups only
- IAM → Users → create a user with no console access.
- Open the user → Security credentials tab → Create access key.
- For the use case, choose Other → Next → Create access key.
- On Retrieve access keys, choose Show or Download .csv file. AWS shows the secret only this once.
3. Give it these four permissions, and no more
- Attach the policy below to that user as an inline policy.
- Replace
BUCKETwith your bucket, andgitbackups/with the prefix you will type into Gitbackups (BUCKET/*if you use none).
{
"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
Bucket → Management → Create lifecycle rule → apply to the whole bucket.
Tick “Delete expired object delete markers or incomplete multipart uploads” and set 1 day.
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 AWS S3 as your storage. Here is each field in the form, and what AWS calls the value that goes in it.
- Region
AWS RegionThe region the bucket is in, as a code like
eu-west-1, not a name like “Europe (Ireland)”. - EndpointoptionalNo label of its own
Leave it blank. We build it from the region:
https://s3.<region>.amazonaws.com. - BucketrequiredThe name only. Not a URL.
Bucket nameWhat you named the bucket in step 1.
- Path prefixoptionalUse one if anything else writes to this bucket.No label of its own
The folder in your step 3 policy, e.g.
gitbackups/. Must match it exactly. - Access key IDrequiredWe only ever show its last four characters.
Access key IDOn the Retrieve access keys page in step 2, and in the .csv.
- Secret access keyrequiredEncrypted on arrival. Never shown again.
Secret access keyChoose Show on that same page, or open the .csv. Lost it? Create 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 AWS S3 bucket.
Setting up a different provider? Cloudflare R2 · Backblaze B2 · Wasabi · MinIO and other S3-compatible storage