News for hackers. Stuff that matters.
Re:Tell HN: GitHub will delete your private repo if you lose... by sangnoir on Tuesday January 31, 2023 @06:39PM (#34604003)
If you have a Raspberry Pi wasting away in a drawer[0], I strongly recommend installing Gitea or Forgejo and mirroring all the repos you like (i.e. the ones you contribute(d) to and/or starred, not just on Github too!). You set it up once and it will sync in upstream changes as often as you like (default is daily)

0. Or a homelab, or a cheap 256MB VM, or a NAS that can run docker containers, or an old Chromebook: anything that can execute a Go binary, x64, arm6 or even mips

Re:Tell HN: GitHub will delete your private repo if you lose... by kitkat_new on Tuesday January 31, 2023 @06:52PM (#34604138)
I'll look for a tool that mirrors all my repositories (i.e. only forks). If I can't find one, I'll write it myself.
Re:Tell HN: GitHub will delete your private repo if you lose... by jmondi on Tuesday January 31, 2023 @07:52PM (#34604739)
I wrote a little tool to mirror my repositories to my gitea instance. It has been months to potentially a year or two since I ran this, but it does what you’re asking. You can mirror repositories of users and repos users have starred. It definitely needs some love.

https://github.com/jasonraimondi/deno-mirror-to-gitea

Re:Tell HN: GitHub will delete your private repo if you lose... by mckn1ght on Wednesday February 01, 2023 @08:05PM (#34620612)
I wrote a similar one I called Forgery that’s in a repo of the same name in my github account (which can be found in my user profile… just created this account and didn’t want to post a link in my first post, thought it might get automodded).

Very similar to yours, but also does forks, which I’m not sure yours does by a quick glance at your readme. Although, mine doesn’t automatically mirror from another forge, just clones everything locally. I’ll have to add a TODO to add mirroring.

Please have a look at how I handle them and consider adding a link to my project in your “similar tools” section, and I’ll do the same for you!

Re:Tell HN: GitHub will delete your private repo if you lose... by jmondi on Friday February 03, 2023 @06:49PM (#34649541)
If I remember correctly, I believe that mine will do forks also, they are just included in in your repositories.

I just looked over your project, and it seems pretty cool. A little bit different than mine, since mine is specifically github to a gitea mirror repository. I don't mind adding a link to your project in mine.

Thanks for sharing!

Re:Tell HN: GitHub will delete your private repo if you lose... by pabs3 on Tuesday January 31, 2023 @09:32PM (#34605596)
Re:Tell HN: GitHub will delete your private repo if you lose... by drudoo on Wednesday February 01, 2023 @09:34AM (#34610970)
This is build in to Gitea. I mirror multiple github repos to my private gitea instance.
Re:Tell HN: GitHub will delete your private repo if you lose... by remram on Tuesday January 31, 2023 @08:36PM (#34605134)
I wonder if there is an efficient way to do direct incremental git-to-S3 backups, or if you have to do this, run a Git mirror and do regular filesystem-level backups of it.
Re:Tell HN: GitHub will delete your private repo if you lose... by anshumankmr on Tuesday January 31, 2023 @11:05PM (#34606201)
a cron job ought to do this. Try something like Cloud Scheduler that can automate this for you.( I am not sure what the equivalent is in AWS)
Re:Tell HN: GitHub will delete your private repo if you lose... by remram on Wednesday February 01, 2023 @10:46AM (#34612125)
My question is not how to run it, but what to run. If your scheduled task does a full clone every time to upload as ZIP to S3, it is massively inefficient. Even if you use something like Restic, because the Git pack file will have nothing in common with the previous one.
Re:Tell HN: GitHub will delete your private repo if you lose... by saltcured on Wednesday February 01, 2023 @02:20PM (#34616055)
Clone each repo locally. Periodically do "git fetch -p" for each repo to update the local copy of upstream content. Run some periodic task like restic or rclone (depending on whether you want point in time snapshots or just a mirror of latest state) to mirror these local repos into your S3 bucket.

The local clones should evolve incrementally due to "git fetch", and then the restic or rclone task should figure out how to make incremental updates to the S3 content.

Re:Tell HN: GitHub will delete your private repo if you lose... by remram on Wednesday February 01, 2023 @08:34PM (#34620856)
That is what I said.

Again, I wonder if there is a direct way to do this, without a local filesystem with a Git mirror that you do filesystem-level backups of.

Re:Tell HN: GitHub will delete your private repo if you lose... by saltcured on Thursday February 02, 2023 @02:06PM (#34631542)
I had trouble parsing your earliest comment, so I only tried to address the incremental backup concern. I may not have understood the conversation, but it seemed like you claimed that a filesystem level backup of a clone was not going to produce incremental backup IO in practice.

A periodic fetch into a persistent cloned repo will be incremental unless the upstream is doing something crazy with frequent branch deletions and repacks. In practice, most upstream repos I encounter behave relatively monotonically. They accumulate new commits and branch/tag heads but do not often create garbage or need repacking.

A periodic backup of the cloned repo will also be incremental if using an appropriate tool like restic or rclone-copy. Also, since the clone only changes during the fetch, you can serialize these in one periodic job and be confident that you are making a consistent snapshot of the repo.

The advantage of this approach is its simplicity. It is easy to reason about and easy to work with the backups to restore a repo without having to learn about other tools. It's the kind of thing I could feel comfortable setting up and running for years on end with little supervision.

A more sophisticated approach that integrates with git hooks, e.g. to do event-driven rather than periodic backup, is plausible but I think could quickly get in the way of itself. And if working with a hosted upstream, you would need to integrate with their proprietary hooks, e.g. GitHub actions, and deal with other restrictions of the hosting environment. Such a solution likely brings new failure modes and may not be a worthwhile tradeoff...

Re:Tell HN: GitHub will delete your private repo if you lose... by remram on Friday February 03, 2023 @04:10PM (#34647755)
Again, this requires you to have a persistent clone on a filesystem. I specifically wonder if we can do (and I quote) "direct incremental git-to-S3 backups", and you keep replying "it's easy, do it indirectly with a persistent cloned repo".

I don't understand where you are stuck, tbh.

yencabulator has provided a good tip I think, as you could store the previous set of refs and use that to build an incremental Git bundle (one with only the objects that were not in the previous bundle). I don't know if you can do that with the existing Git client though.

Re:Tell HN: GitHub will delete your private repo if you lose... by yencabulator on Wednesday February 01, 2023 @08:35PM (#34620870)
https://git-scm.com/docs/git-bundle creates a single file that contains everything in A not in B, so e.g. the delta between the state of the repository yesterday and the state today (for all the refs in it). You just need to produce the "rev list" to save.