sql: Begin cleanup of code

This commit is contained in:
Tom Wiesing 2022-09-19 13:03:59 +02:00
parent b0d3c686ba
commit f7b8804c61
No known key found for this signature in database
8 changed files with 158 additions and 135 deletions

View 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
}