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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Options:
The target path to the backup folder. (default "backup")
-config.file string
The path to your config file. (default "git-backup.yml")
-backup.fail-at-end
Fail at the end of backing up repositories, rather than right away.
```

## Usage: Docker
Expand Down
13 changes: 11 additions & 2 deletions cmd/git-backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

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.")

func main() {
flag.Parse()
Expand All @@ -22,6 +23,7 @@ func main() {
os.Exit(111)
}
repoCount := 0
errors := 0
backupStart := time.Now()
for _, source := range sources {
sourceName := source.GetName()
Expand All @@ -45,13 +47,20 @@ func main() {
}
err = repo.CloneInto(targetPath)
if err != nil {
errors++
log.Printf("Failed to clone: %s", err)
os.Exit(100)
if *failAtEnd == false {
os.Exit(100)
}
}
}
repoCount++
}
log.Printf("Backed up %d repositories in %s", repoCount, time.Now().Sub(backupStart))
log.Printf("Backed up %d repositories in %s, encountered %d errors", repoCount, time.Now().Sub(backupStart), errors)

if errors > 0 {
os.Exit(100)
}
}

func loadConfig() gitbackup.Config {
Expand Down