@@ -163,14 +163,9 @@ func (b *PostgresBackup) doPostgresBackup() (string, error) {
163163 args = append (args , b .cfg .PostgresDatabase )
164164 }
165165
166- // Prepare command
167- cmd := exec .Command ("pg_dump" , args ... )
168- // Pass password via environment variable
169- cmd .Env = append (os .Environ (), fmt .Sprintf ("PGPASSWORD=%s" , b .cfg .PostgresPassword ))
170-
171166 // Dump to a timestamped file in the temp directory
172167 ts := time .Now ().Format ("20060102-150405" )
173- outfile := fmt .Sprintf ("%s/%s-backup-%s.sql.gz " , b .tempDir , b .cfg .PostgresDatabase , ts )
168+ outfile := fmt .Sprintf ("%s/%s-backup-%s.sql" , b .tempDir , b .cfg .PostgresDatabase , ts )
174169 f , err := os .Create (outfile )
175170 if err != nil {
176171 slog .Error ("Failed to create dump file" , "file" , outfile , "error" , err )
@@ -182,6 +177,12 @@ func (b *PostgresBackup) doPostgresBackup() (string, error) {
182177 slog .Error ("Failed to close dump file" , "file" , outfile , "error" , err )
183178 }
184179 }(f )
180+ args = append (args , "-f" , outfile )
181+
182+ // Prepare command
183+ cmd := exec .Command ("pg_dump" , args ... )
184+ // Pass password via environment variable
185+ cmd .Env = append (os .Environ (), fmt .Sprintf ("PGPASSWORD=%s" , b .cfg .PostgresPassword ))
185186
186187 // Create gzip writer for compression
187188 gzipWriter := gzip .NewWriter (f )
0 commit comments