internal/dis/component/sql: Fix backup for mariadb
This commit is contained in:
parent
865959f530
commit
b084e3673b
3 changed files with 10 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ func (*SQL) BackupName() string {
|
||||||
// Backup makes a backup of all SQL databases into the path dest.
|
// Backup makes a backup of all SQL databases into the path dest.
|
||||||
func (sql *SQL) Backup(scontext *component.StagingContext) error {
|
func (sql *SQL) Backup(scontext *component.StagingContext) error {
|
||||||
return scontext.AddFile("", func(ctx context.Context, file io.Writer) error {
|
return scontext.AddFile("", func(ctx context.Context, file io.Writer) error {
|
||||||
code := sql.Stack().Exec(ctx, stream.NewIOStream(file, scontext.Progress(), nil, 0), "sql", "mysqldump", "--all-databases")()
|
code := sql.Stack().Exec(ctx, stream.NewIOStream(file, scontext.Progress(), nil, 0), "sql", SQlDumpExecutable, "--all-databases")()
|
||||||
if code != 0 {
|
if code != 0 {
|
||||||
return errSQLBackup
|
return errSQLBackup
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ func (sql *SQL) Snapshot(wisski models.Instance, scontext *component.StagingCont
|
||||||
|
|
||||||
// SnapshotDB makes a backup of the sql database into dest.
|
// SnapshotDB makes a backup of the sql database into dest.
|
||||||
func (sql *SQL) SnapshotDB(ctx context.Context, progress io.Writer, dest io.Writer, database string) error {
|
func (sql *SQL) SnapshotDB(ctx context.Context, progress io.Writer, dest io.Writer, database string) error {
|
||||||
code := sql.Stack().Exec(ctx, stream.NewIOStream(dest, progress, nil, 0), "sql", "mysqldump", "--databases", database)()
|
code := sql.Stack().Exec(ctx, stream.NewIOStream(dest, progress, nil, 0), "sql", SQlDumpExecutable, "--databases", database)()
|
||||||
if code != 0 {
|
if code != 0 {
|
||||||
return errSQLBackup
|
return errSQLBackup
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,3 +58,11 @@ func (sql *SQL) Stack() component.StackWithResources {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// "mysql"-compatible executable for raw sql queries
|
||||||
|
SQLQueryExecutable = "mariadb"
|
||||||
|
|
||||||
|
// "mysqldump"-compatible executable for dumping an entire database
|
||||||
|
SQlDumpExecutable = "mariadb-dump"
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue