Skip to content

Commit

Permalink
Fix: Backup name
Browse files Browse the repository at this point in the history
  • Loading branch information
sadihakan committed Apr 1, 2021
1 parent a280192 commit 72ea7f4
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 11 deletions.
Binary file added .backup
Binary file not shown.
6 changes: 0 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package config

import (
"github.com/sadihakan/dummy-dump/errors"
"strconv"
"time"
)

type Config struct {
Expand Down Expand Up @@ -43,10 +41,6 @@ func (c *Config) checkAll() error {
c.Path = "."
}

if c.BackupName == "" {
c.BackupName = strconv.FormatInt(time.Now().UTC().UnixNano(), 10)
}

return nil
}

Expand Down
5 changes: 1 addition & 4 deletions example/dummy_dump_example.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
dummydump "github.com/sadihakan/dummy-dump"
"github.com/sadihakan/dummy-dump/config"
)
Expand All @@ -16,15 +15,13 @@ func main() {
Path: "",
DB: "test",
BinaryPath: "/usr/local/opt/postgresql@12/bin/pg_dump",
BackupName: "test",
BackupName: "",
})

if err != nil {
panic(err)
}

fmt.Println(dd.GetBinary())


if _, err = dd.Check().Export().Run(); err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func getImportCommandArg(cfg config.Config) (arg []string) {

// getExportCommandArg ...
func getExportCommandArg(cfg config.Config) (arg []string) {
filename := fmt.Sprintf("%s/%s.backup", cfg.Path, cfg.BackupName)
filename := fmt.Sprintf("%s.backup", cfg.BackupName)
switch cfg.Source {
case config.PostgreSQL:
dns := fmt.Sprintf(`user=%s password=%s dbname=%s`, cfg.User, cfg.Password, cfg.DB)
Expand Down
2 changes: 2 additions & 0 deletions internal/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"bytes"
"errors"
"fmt"
"github.com/sadihakan/dummy-dump/config"
"os"
)
Expand All @@ -28,6 +29,7 @@ func (p Postgres) Export(dump config.Config) error {
var out, errBuf bytes.Buffer

cmd := CreateExportCommand(dump)
fmt.Println(cmd)
cmd.Stdout = &out
cmd.Stderr = &errBuf
err := cmd.Run()
Expand Down
Binary file modified test.backup
Binary file not shown.

0 comments on commit 72ea7f4

Please sign in to comment.