@@ -32,6 +32,7 @@ import (
32
32
"os"
33
33
"os/exec"
34
34
"path/filepath"
35
+
"runtime"
35
36
"strings"
36
37
"sync"
37
38
"time"
@@ -558,7 +559,7 @@ func (d *dump) dump(fc chan<- sumFileJob) error {
558
559
file := formatDumpPath(d.Directory, d.TimeFormat, fileEnd, dbname, d.When)
559
560
formatOpt := fmt.Sprintf("-F%c", d.Options.Format)
560
561
561
-
command := filepath.Join(binDir, "pg_dump")
562
+
command := execPath("pg_dump")
562
563
args := []string{formatOpt, "-f", file, "-w"}
563
564
564
565
if fileEnd == "d" && d.Options.Jobs > 1 {
@@ -692,6 +693,14 @@ func relPath(basedir, path string) string {
692
693
return target
693
694
}
694
695
696
+
func execPath(prog string) string {
697
+
if binDir != "" && runtime.GOOS == "windows" {
698
+
return filepath.Join(binDir, fmt.Sprintf("%s.exe", prog))
699
+
}
700
+
701
+
return prog
702
+
}
703
+
695
704
func cleanDBName(dbname string) string {
696
705
// We do not want a database name starting with a dot to avoid creating hidden files
697
706
if strings.HasPrefix(dbname, ".") {
@@ -737,7 +746,7 @@ func formatDumpPath(dir string, timeFormat string, suffix string, dbname string,
737
746
}
738
747
739
748
func pgToolVersion(tool string) int {
740
-
vs, err := exec.Command(filepath.Join(binDir, tool), "--version").Output()
749
+
vs, err := exec.Command(execPath(tool), "--version").Output()
741
750
if err != nil {
742
751
l.Warnf("failed to retrieve version of %s: %s", tool, err)
743
752
return 0
@@ -766,7 +775,7 @@ func pgToolVersion(tool string) int {
766
775
}
767
776
768
777
func dumpGlobals(dir string, timeFormat string, conninfo *ConnInfo, fc chan<- sumFileJob) error {
769
-
command := filepath.Join(binDir, "pg_dumpall")
778
+
command := execPath("pg_dumpall")
770
779
args := []string{"-g", "-w"}
771
780
772
781
// pg_dumpall only connects to another database if it is given
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4