diff --git a/backend/utils/mysql/client/local.go b/backend/utils/mysql/client/local.go
index 5e5fe7e5746e..b79c736169fa 100644
--- a/backend/utils/mysql/client/local.go
+++ b/backend/utils/mysql/client/local.go
@@ -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"
diff --git a/backend/utils/mysql/client/remote.go b/backend/utils/mysql/client/remote.go
index 17ea7029f8b0..1229c2f5dcfb 100644
--- a/backend/utils/mysql/client/remote.go
+++ b/backend/utils/mysql/client/remote.go
@@ -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"
diff --git a/backend/utils/postgresql/client/local.go b/backend/utils/postgresql/client/local.go
index 4b927e78c9b1..1e0e15f6bb18 100644
--- a/backend/utils/postgresql/client/local.go
+++ b/backend/utils/postgresql/client/local.go
@@ -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")