Introduction
I built a GitHub Actions workflow that automatically backs up GitHub repositories to AWS S3.
The workflow is available as a template repository on GitHub:
Feel free to try it out if youâre interested!
Motivation
The idea came from this blog post I recently read:
đ Why You Should Keep Multiple Backups of Your Code (Donât Rely Only on GitHub)
The author emphasized the importance of not relying solely on GitHub and keeping backups of your repositories. After reading it, I decided to set up my own backup system.
That article demonstrated how to automate local backups using cron or Task Scheduler. However, since my computer isnât always running, I wanted a fully online, serverless approach. Thatâs when I thought:
âWhy not leverage GitHub Actionsâ scheduled workflows?â
So, I gave it a try.
How It Works
Workflow steps
- Run on schedule with GitHub Actions
-
git clone --mirrorthe target repository - Create a bundle file
- Upload the bundle to an S3 bucket
What gets backed up
- Full commit history (all branches & tags)
- Branch and tag references
- Remote configuration & refs
What doesnât get backed up
- Issues / Pull Requests / Projects / Discussions / Actions history
- Wiki or static files in GitHub Pages
- Repository settings (e.g., Branch Protection rules)
Lessons Learned
A couple of tricky points during implementation:
awscli installation
Initially, I tried installing awscli in the workflow runner and ran into errors. Turns out itâs already pre-installed on GitHub-hosted runnersâso no installation step was needed.
GitHub Personal Access Token authentication
I first tried with Fine-grained Personal Access Tokens, but authentication failed. Switching to a Classic Token with repo scope solved the issue.
Interestingly, GitHub Copilot was really helpful hereâit suggested possible causes and fixes when my workflow runs failed.
Publishing the Template
After testing it on my own repositories and confirming the backups worked, I decided to publish it as a template repository.
My reasons:
- Someone else might find it useful
- It adds to my portfolio
- It gives me something to blog about
In other words, three birds with one stone.
To make it easier for others to use, I:
- Wrote all workflow comments in English
- Provided a multi-language README (Japanese & English)
- Added an MIT license for clarity
Whatâs Next
This project is still new, so I donât have a detailed roadmap yet. But for now, my plans are:
- Run it for my own repositories for a while
- Collect user feedback
- Consider S3 lifecycle policies (storage cost optimization, automated deletion, etc.)
If you have suggestions for improvement, Iâd love to hear them!
Final Thoughts
This project started when reading an English blog post (as part of my language learning), which unexpectedly connected with something else I had learned earlierâGitHub Actions for automating React deployments.
It reminded me how valuable it is to keep gathering new inputs and ideasâyou never know when theyâll connect.
Building this workflow was fun because I got to use GitHub Actions, GitHub Copilot, and AWS together.
Iâm looking forward to making more small tools like this that might help othersâwhile enjoying the process.
