mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-29 18:26:03 +08:00
fix: Fix PostgreSQL database recovery failures (#9867)
This commit is contained in:
parent
3c967f8906
commit
e3a9f2dfb7
2 changed files with 2 additions and 2 deletions
|
|
@ -167,7 +167,7 @@ func (r *Local) Recover(info RecoverInfo) error {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(info.Timeout*uint(time.Second)))
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, "docker", "exec", "-i", r.ContainerName, "sh", "-c",
|
||||
fmt.Sprintf("PGPASSWORD=%s pg_restore -F c -U %s -d %s", r.Password, r.Username, info.Name),
|
||||
fmt.Sprintf("PGPASSWORD=%s pg_restore -F c -c --if-exists --no-owner -U %s -d %s", r.Password, r.Username, info.Name),
|
||||
)
|
||||
if strings.HasSuffix(info.SourceFile, ".gz") {
|
||||
gzipFile, err := os.Open(info.SourceFile)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ func (r *Remote) Recover(info RecoverInfo) error {
|
|||
}()
|
||||
}
|
||||
recoverCommand := exec.Command("bash", "-c",
|
||||
fmt.Sprintf("docker run --rm --net=host -i %s /bin/bash -c 'PGPASSWORD=\"%s\" pg_restore -h %s -p %d --verbose --clean --no-privileges --no-owner -Fc -U %s -d %s --role=%s' < %s",
|
||||
fmt.Sprintf("docker run --rm --net=host -i %s /bin/bash -c 'PGPASSWORD=\"%s\" pg_restore -h %s -p %d --verbose --clean --no-privileges --no-owner -Fc -c --if-exists --no-owner -U %s -d %s --role=%s' < %s",
|
||||
imageTag, r.Password, r.Address, r.Port, r.User, info.Name, info.Username, fileName))
|
||||
pipe, _ := recoverCommand.StdoutPipe()
|
||||
stderrPipe, _ := recoverCommand.StderrPipe()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue