Skip to content

Commit

Permalink
fix: 解决升级过程中备份错误问题 (#5120)
Browse files Browse the repository at this point in the history
Refs #5103
  • Loading branch information
ssongliu committed May 23, 2024
1 parent 99ed9be commit 9c357f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions backend/utils/mysql/client/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ func (r *Local) Backup(info BackupInfo) error {
}
}
outfile, err := os.OpenFile(path.Join(info.TargetDir, info.FileName), os.O_RDWR|os.O_CREATE, 0755)
if err == nil {
defer outfile.Close()
if err != nil {
return fmt.Errorf("open file %s failed, err: %v", path.Join(info.TargetDir, info.FileName), err)
}
defer outfile.Close()
dumpCmd := "mysqldump"
if r.Type == constant.AppMariaDB {
dumpCmd = "mariadb-dump"
Expand Down
5 changes: 3 additions & 2 deletions backend/utils/mysql/client/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,10 @@ func (r *Remote) Backup(info BackupInfo) error {
}
}
outfile, err := os.OpenFile(path.Join(info.TargetDir, info.FileName), os.O_RDWR|os.O_CREATE, 0755)
if err == nil {
defer outfile.Close()
if err != nil {
return fmt.Errorf("open file %s failed, err: %v", path.Join(info.TargetDir, info.FileName), err)
}
defer outfile.Close()
dumpCmd := "mysqldump"
if r.Type == constant.AppMariaDB {
dumpCmd = "mariadb-dump"
Expand Down
5 changes: 3 additions & 2 deletions backend/utils/postgresql/client/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ func (r *Local) Backup(info BackupInfo) error {
}
}
outfile, err := os.OpenFile(path.Join(info.TargetDir, info.FileName), os.O_RDWR|os.O_CREATE, 0755)
if err == nil {
defer outfile.Close()
if err != nil {
return fmt.Errorf("open file %s failed, err: %v", path.Join(info.TargetDir, info.FileName), err)
}
defer outfile.Close()
global.LOG.Infof("start to pg_dump | gzip > %s.gzip", info.TargetDir+"/"+info.FileName)
cmd := exec.Command("docker", "exec", r.ContainerName, "pg_dump", "-F", "c", "-U", r.Username, "-d", info.Name)
gzipCmd := exec.Command("gzip", "-cf")
Expand Down

0 comments on commit 9c357f1

Please sign in to comment.