GithubHelp home page GithubHelp logo

gh-stars-backup's Introduction

gh-stars-backup

Why?

I needed a way to backup all my starred repositories from Github in case they'll be taken down or made private.

What?

This binary clones (pulls if they're already cloned) all your starred repos from github.

How?

The binary lists all your starred repositories and calls git clone for each of them.
If they already exist, it calls git pull instead.

Requirements

  • you must have git installed.
  • you will need a Github PAT (personal access token) with scope repo and user.

Installation

  • if you have go installed: go install github.com/DeluxeOwl/gh-stars-backup@latest
  • install the binary for your OS from the github releases tab.

Usage

$ ./gh-stars-backup --help
Usage of gh-stars-backup:
  -clone-args string
        arguments for git clone
  -dir-format string
        go template that specifies the format of git directories (default "{{.RepoName}} [{{.RepoAuthor}}]")
  -gh-pat string
        github pat token, scope: repo & user
  -limit int
        goroutine limiter for cloning/pulling repos (default 16)
  -output-dir string
        the directory where the repos will be saved (default "./")
  -pull-args string
        arguments for git pull

It also takes the flags as environment variables if available, transform the flags to uppercase (ex: CLONE_ARGS)

As a binary

./gh-stars-backup -gh-pat=<your_pat_token> -clone-args="--depth 1" -dir-format="{{.RepoName}}_{{.RepoAuthor}}" -output-dir="./ghbackup" | tee out.txt
# or with an env variable only
GH_PAT=<my_pat_token> ./gh-stars-backup

As a docker image

docker build -t gh-stars-backup .

docker run -v `pwd`/test:/ghstars gh-stars-backup -gh-pat=<your_pat_token> -output-dir="./ghstars"
# or if you dont want to build it
docker run -v `pwd`/test:/ghstars nospamplease/gh-stars-backup -gh-pat=<your_pat_token> -output-dir="./ghstars"

As a cronjob

5 13 * * * /path/to/gh-stars-backup -gh-pat=<your_pat_token> -output-dir=<directory_where_you_want_to_save>

As a cronjob in kubernetes

kubectl apply -f https://raw.githubusercontent.com/DeluxeOwl/gh-stars-backup/main/cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: gh-stars-backup
spec:
  schedule: "5 13 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: gh-stars-backup
              image: nospamplease/gh-stars-backup
              imagePullPolicy: IfNotPresent
              command:
                - /bin/sh
                - -c
                - /gh-stars-backup
              env:
                - name: GH_PAT
                  value: <your_pat_token>
          restartPolicy: OnFailure

Development

I use taskfile as a glorified command runner.

gh-stars-backup's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gh-stars-backup's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.