Skip to content

Commit

Permalink
accelerate postgres restore with jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Biptaste committed Feb 15, 2024
1 parent ed11223 commit a516766
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actions/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"

"github.com/Songmu/prompter"
Expand Down Expand Up @@ -295,7 +296,7 @@ func restorePostgres(ctx domain.ExecutionContext, containerID string, dumpFilena
ext := filepath.Ext(dumpFilename)
database := strings.Replace(dumpFilename, ext, "", 1)

cmd := domain.NewCommand([]string{"docker", "exec", "-i", "-e", fmt.Sprintf("PGPASSWORD=\"%s\"", password), containerID, "pg_restore", fmt.Sprintf("--username=%s", user), "-d", database, "-c"}, verbose)
cmd := domain.NewCommand([]string{"docker", "exec", "-i", "-e", fmt.Sprintf("PGPASSWORD=\"%s\"", password), containerID, "pg_restore", fmt.Sprintf("--username=%s", user), "-d", database, "-c", fmt.Sprintf("--jobs=%d", runtime.NumCPU())}, verbose)
cmd.ExecuteWithStdin(postgresDumpReader)
}

Expand Down

0 comments on commit a516766

Please sign in to comment.