sql: Begin cleanup of code
This commit is contained in:
parent
b0d3c686ba
commit
f7b8804c61
8 changed files with 158 additions and 135 deletions
21
internal/component/sql/snapshot.go
Normal file
21
internal/component/sql/snapshot.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package sql
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
// Snapshot makes a backup of the sql database into dest.
|
||||
func (sql SQL) Snapshot(io stream.IOStream, dest io.Writer, database string) error {
|
||||
io = io.Streams(dest, nil, nil, 0).NonInteractive()
|
||||
|
||||
code, err := sql.Stack(sql.Environment).Exec(io, "sql", "mysqldump", "--databases", database)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if code != 0 {
|
||||
return errSQLBackup
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue