Skip to content

Commit

Permalink
Fix #62 - GitHub user migration retry (#63)
Browse files Browse the repository at this point in the history
Attempt at creating a user migration after 5 minutes, if it fails.
This is of course quick and dirty to validate if this will work.

The interesting thing is the migration does work on the GitHub side,
since i get an email saying the migration is ready and I can download
it.
  • Loading branch information
amitsaha authored Dec 12, 2021
1 parent 8e42c81 commit fa5e695
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
"log"
"net/url"
"sync"
"time"

"github.com/google/go-github/v34/github"
)
@@ -49,7 +50,7 @@ func main() {
githubRepoType := flag.String("github.repoType", "all", "Repo types to backup (all, owner, member, starred)")

githubCreateUserMigration := flag.Bool("github.createUserMigration", false, "Download user data")

githubCreateUserMigrationRetry := flag.Bool("github.createUserMigrationRetry", true, "Retry creating the user migration if we get an error")
githubListUserMigrations := flag.Bool("github.listUserMigrations", false, "List available user migrations")
githubWaitForMigrationComplete := flag.Bool("github.waitForUserMigration", true, "Wait for migration to complete")

@@ -115,7 +116,15 @@ func main() {
log.Printf("Creating a user migration for %d repos", len(repos))
m, err := createGithubUserMigration(context.Background(), client, repos)
if err != nil {
log.Fatalf("Error creating migration: %v", err)
if !*githubCreateUserMigrationRetry {
log.Fatalf("Error creating migration: %v", err)
}
log.Printf("Got error when creating migration: %v. Retrying after sleeping for 300 seconds.", err)
time.Sleep(300 * time.Second)
m, err = createGithubUserMigration(context.Background(), client, repos)
if err != nil {
log.Fatalf("Error creating migration: %v", err)
}
}
if *githubWaitForMigrationComplete {
downloadGithubUserMigrationData(client, *backupDir, m.ID)

0 comments on commit fa5e695

Please sign in to comment.