Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Own your data: mirroring your Github

Yes, you SHOULD own your da­ta. Specif­i­cal­ly, if you are cod­ing some­thing, you should own it. And I don't mean own­ing in the sense of "I have the copy­right" be­cause sure, you al­ready do. There are thou­sands of lines of code I wrote in the 90s and 2000s of which there is no ex­tant copy. NONE. Weeks and months of code, all gone, for­ev­er.

I mean own in the sense of HAV­ING A COPY OF IT. You should have a copy of your code.

No, hav­ing it up in GitHub is not the same as hav­ing a copy, be­cause you may lose the ac­count (seen it hap­pen) or delete the re­po (done it ac­ci­den­tal­ly) or they may just delete it for what­ev­er rea­son (it hap­pens)

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, us­ing Git­Lab in­stead or in ad­di­tion to GitHub is not the same as own­ing a copy.

So, how do you own a copy?

You set­up your own pri­vate GitHub-­like-thingie.

My favourite one is Gitea ... it does 80% of what GitHub does, for free, from a sin­gle self­-­con­tained bi­na­ry and it runs just fine in a Rasp­ber­ry Pi 3.

It has a fea­ture to clone a GH re­po. It will pe­ri­od­i­cal­ly clone all the branch­es, and keep them up to date. You can then con­tin­ue to work as usu­al and it will do its thing in the back­ground, unat­tend­ed.

Or you can use it as source of truth and make GH the mir­ror. Your choice.

So, what's left? Mak­ing a copy of all your GH re­pos.

Turns out there is a nice script to do that: http­s://github.­com/­jaedle/mir­ror-­to-gitea

You will need:

  • Gitea run­ning some­where with some free disk space
  • Dock­er run­ning some­where
  • Gen­er­ate a app to­ken in Gitea
  • Fol­low sim­ple in­struc­tions (it's one com­mand)
  • Wait from a few min­utes to a few hours, de­pend­ing on how much you are mir­ror­ing.

And voilá.


Contents © 2000-2023 Roberto Alsina