Skip to content

Commit

Permalink
feat: add different dbTypes file format
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsttt committed Apr 13, 2024
1 parent ea98088 commit 7f1860a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7f1860a

Please sign in to comment.