Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: '^1.17.8'
- run: ${{ matrix.goopts }} go build -o ${{ matrix.filename }} ./cmd/git-backup
- run: ${{ matrix.goopts }} go build -o ${{ matrix.filename }} -ldflags="-X 'main.Version=${GITHUB_REF##*/}' -X 'main.CommitHash=${GITHUB_SHA}' -X 'main.BuildTimestamp=$(date)'" ./cmd/git-backup
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ Options:
-backup.fail-at-end
Fail at the end of backing up repositories, rather than right away.
-backup.bare-clone
Make bare clones without checking out the main branch.
Make bare clones without checking out the main branch.
-version
Show the version number and exit.
```

## Usage: Docker
Expand Down
12 changes: 12 additions & 0 deletions cmd/git-backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@ import (
"log"
"os"
"path/filepath"
"runtime"
"time"
)

var configFilePath = flag.String("config.file", "git-backup.yml", "The path to your config file.")
var targetPath = flag.String("backup.path", "backup", "The target path to the backup folder.")
var failAtEnd = flag.Bool("backup.fail-at-end", false, "Fail at the end of backing up repositories, rather than right away.")
var bareClone = flag.Bool("backup.bare-clone", false, "Make bare clones without checking out the main branch.")
var printVersion = flag.Bool("version", false, "Show the version number and exit.")

var Version = "dev"
var CommitHash = "n/a"
var BuildTimestamp = "n/a"

func main() {
flag.Parse()

if *printVersion {
log.Printf("git-backup, version %s (%s-%s)", Version, runtime.GOOS, runtime.GOARCH)
log.Printf("Built %s (%s)", CommitHash, BuildTimestamp)
os.Exit(0)
}

config := loadConfig()
sources := config.GetSources()
if len(sources) == 0 {
Expand Down