Own your data: mirroring your Github
Yes, you SHOULD own your data. Specifically, if you are coding something, you should own it. And I don't mean owning in the sense of "I have the copyright" because sure, you already do. There are thousands of lines of code I wrote in the 90s and 2000s of which there is no extant copy. NONE. Weeks and months of code, all gone, forever.
I mean own in the sense of HAVING A COPY OF IT. You should have a copy of your code.
No, having it up in GitHub is not the same as having a copy, because you may lose the account (seen it happen) or delete the repo (done it accidentally) or they may just delete it for whatever reason (it happens)
No, having it up in GitHub and having a git clone
in your machine is not enough, because you are not going to
pull every day, and checkout every branch.
No, using GitLab instead or in addition to GitHub is not the same as owning a copy.
So, how do you own a copy?
You setup your own private GitHub-like-thingie.
My favourite one is Gitea ... it does 80% of what GitHub does, for free, from a single self-contained binary and it runs just fine in a Raspberry Pi 3.
It has a feature to clone a GH repo. It will periodically clone all the branches, and keep them up to date. You can then continue to work as usual and it will do its thing in the background, unattended.
Or you can use it as source of truth and make GH the mirror. Your choice.
So, what's left? Making a copy of all your GH repos.
Turns out there is a nice script to do that: https://github.com/jaedle/mirror-to-gitea
You will need:
- Gitea running somewhere with some free disk space
- Docker running somewhere
- Generate a app token in Gitea
- Follow simple instructions (it's one command)
- Wait from a few minutes to a few hours, depending on how much you are mirroring.
And voilá.