diff --git a/dump.go b/dump.go index 29ab1d1..a3d2ced 100644 --- a/dump.go +++ b/dump.go @@ -107,6 +107,12 @@ func commandExist(command string) bool { return err == nil } -func newFileName(db string) string { - return fmt.Sprintf(`%v_%v.pgdump`, db, time.Now().Unix()) +func newFileName(db string, dbType string) string { + switch dbType { + case "postgres": + return fmt.Sprintf(`%v_%v.pgdump`, db, time.Now().Unix()) + case "mysql": + return fmt.Sprintf(`%v_%v.sql`, db, time.Now().Unix()) + } + return fmt.Sprintf(`%v_%v`, db, time.Now().Unix()) } diff --git a/main.go b/main.go index 6691f44..b005e00 100644 --- a/main.go +++ b/main.go @@ -81,7 +81,7 @@ func main() { for { for _, u := range urls { log.Printf("Backing up %s", u.Database) - file := newFileName(u.Database) + file := newFileName(u.Database, u.DbType) if err = RunDump(&u, file); err != nil { log.Printf("WARNING: Failed to dump database: %s", err)