mirror of https://github.com/1Panel-dev/1Panel
fix(database-pg): Fixed the issue of PostgreSQL not being able to back up. (#7324)
parent
cbad4dd172
commit
aaf1d86a55
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -134,7 +135,7 @@ func (r *Remote) Backup(info BackupInfo) error {
|
|||
}
|
||||
fileNameItem := info.TargetDir + "/" + strings.TrimSuffix(info.FileName, ".gz")
|
||||
backupCommand := exec.Command("bash", "-c",
|
||||
fmt.Sprintf("docker run --rm --net=host -i %s -e PGPASSWORD='%s' /bin/bash -c 'pg_dump -h %s -p %d --no-owner -Fc -U %s %s' > %s",
|
||||
fmt.Sprintf("docker run --rm --net=host -i %s /bin/bash -c 'PGPASSWORD=%s pg_dump -h %s -p %d --no-owner -Fc -U %s %s' > %s",
|
||||
imageTag, r.Password, r.Address, r.Port, r.User, info.Name, fileNameItem))
|
||||
_ = backupCommand.Run()
|
||||
b := make([]byte, 5)
|
||||
|
@ -177,7 +178,7 @@ func (r *Remote) Recover(info RecoverInfo) error {
|
|||
}()
|
||||
}
|
||||
recoverCommand := exec.Command("bash", "-c",
|
||||
fmt.Sprintf("docker run --rm --net=host -i %s -e PGPASSWORD='%s' /bin/bash -c '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 -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()
|
||||
|
@ -296,7 +297,11 @@ func loadImageTag() (string, error) {
|
|||
return itemTag, nil
|
||||
}
|
||||
|
||||
itemTag = "postgres:16.1-alpine"
|
||||
sort.Strings(versions)
|
||||
if len(versions) != 0 {
|
||||
itemTag = versions[len(versions)-1]
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
|
||||
defer cancel()
|
||||
if _, err := client.ImagePull(ctx, itemTag, image.PullOptions{}); err != nil {
|
||||
|
|
|
@ -1834,7 +1834,7 @@ const message = {
|
|||
gotoInstalled: 'Go to install',
|
||||
search: 'Search',
|
||||
limitHelper: 'The application has already been installed.',
|
||||
deleteHelper: `"{0}" has been associated with the following resource(s) and can't be deleted`,
|
||||
deleteHelper: `"{0}" has been associated with the following resource(s). Please check and try again!`,
|
||||
checkTitle: 'Hint',
|
||||
website: 'website',
|
||||
database: 'database',
|
||||
|
|
|
@ -1716,7 +1716,7 @@ const message = {
|
|||
gotoInstalled: '去安裝',
|
||||
search: '搜索',
|
||||
limitHelper: '該應用已安裝,不支持重復安裝',
|
||||
deleteHelper: '{0}已經關聯以下資源,無法刪除',
|
||||
deleteHelper: '{0}已經關聯以下資源,請檢查後重試!',
|
||||
checkTitle: '提示',
|
||||
website: '網站',
|
||||
database: '數據庫',
|
||||
|
|
|
@ -1715,7 +1715,7 @@ const message = {
|
|||
gotoInstalled: '去安装',
|
||||
search: '搜索',
|
||||
limitHelper: '该应用已安装,不支持重复安装',
|
||||
deleteHelper: '{0}已经关联以下资源,无法删除',
|
||||
deleteHelper: '{0}已经关联以下资源,请检查后重试!',
|
||||
checkTitle: '提示',
|
||||
website: '网站',
|
||||
database: '数据库',
|
||||
|
|
Loading…
Reference in New Issue