Implement initial 'wdcli backup_instance' command
This commit performs an initial implementation of the 'backup_instance' command.
This commit is contained in:
parent
a64c02cd78
commit
2a14d93d3c
17 changed files with 437 additions and 135 deletions
17
env/stack_sql.go
vendored
17
env/stack_sql.go
vendored
|
|
@ -2,6 +2,7 @@ package env
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"time"
|
||||
|
||||
|
|
@ -76,6 +77,22 @@ func (dis *Distillery) sqlBkTable(silent bool) (*gorm.DB, error) {
|
|||
return table, nil
|
||||
}
|
||||
|
||||
var errSQLBackup = errors.New("SQLBackup: Mysqldump returned non-zero exit code")
|
||||
|
||||
// SQLBackup makes a backup of the sql database into dest.
|
||||
func (dis *Distillery) SQLBackup(io stream.IOStream, dest io.Writer, database string) error {
|
||||
io = stream.NewIOStream(dest, io.Stderr, nil, 0)
|
||||
|
||||
code, err := dis.SQLStack().Exec(io, "sql", "mysqldump", "--database", database)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if code != 0 {
|
||||
return errSQLBackup
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SQLShell executes a mysql shell inside the SQLStack.
|
||||
func (dis *Distillery) SQLShell(io stream.IOStream, argv ...string) (int, error) {
|
||||
return dis.SQLStack().Exec(io, "sql", "mysql", argv...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue