Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

New fear unlocked; Being blocked from my github account.

Is there some easy way to mirror everything on GH to a NAS or something?



Search and you'll find various software doing it. If you just want a minimal shell thing for repos themselves, you can fetch a list from GH API for user X and clone them into destination `/home/X/repos` like so:

  $ curl -s https://api.github.com/users/X/repos?per_page=100
    | jq -r 'map([.name,.clone_url]|@tsv)|.[]'
    | xargs -n2 sh -c '[[ -d $0.git ]] || git clone --mirror $1 /home/X/repos/$0.git'
Then you can just put a cronjob to sync them like

  $ find /home/X/repos -maxdepth 1 -mindepth 1 -exec sh -c 'cd {} && git remote update' \;
Replace /users/X with /orgs/Y for an org. Pagination for >100 repos is left as an exercise to the reader.

Note that this will create mirror (bare) repos, so if you want to checkout you can e.g. git clone file:///home/users/X/repos/foo.git somewhere else.

Bonus: If you want to have these mirrors available remotely and self-hosted, the official git book lays out your options pretty nicely: https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protoco...

Easiest are probably git protocol (handled by git itself) or "Dumb HTTP" (just server these directories from a static HTTP server)


https://docs.github.com/en/repositories/archiving-a-github-r...

They say to use a marketplace app if you want an easy way. Or, you can get individual repo archives from their api: https://docs.github.com/en/rest/migrations/users?apiVersion=...


Local gitea can mirror repos


The source code itself is just Git, so you can 'git clone' it anywhere. Add that host to your origin(s) and just push it as you always do.

However, other data such as tickets, PR history, gists, etc. will be a lot harder to keep in sync with another service. GH allows exporting all the data, per GDPR, but importing it somewhere else will probably not be possible.


Exactly, it’s not the code part I see as hard. I don’t want to be locked out of my issues and wikis


Wikis on github are also git repositories which can be cloned.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: