Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ func dumpCmd(passedExecs execs, cmdConfig *cmdConfiguration) (*cobra.Command, er
if !v.IsSet("compact") && dumpConfig != nil && dumpConfig.Compact != nil {
compact = *dumpConfig.Compact
}
// should we dump triggers and functions and procedures?
triggers := v.GetBool("triggers")
if !v.IsSet("triggers") && dumpConfig != nil && dumpConfig.Triggers != nil {
triggers = *dumpConfig.Triggers
}
routines := v.GetBool("routines")
if !v.IsSet("routines") && dumpConfig != nil && dumpConfig.Routines != nil {
routines = *dumpConfig.Routines
}
maxAllowedPacket := v.GetInt("max-allowed-packet")
if !v.IsSet("max-allowed-packet") && dumpConfig != nil && dumpConfig.MaxAllowedPacket != nil && *dumpConfig.MaxAllowedPacket != 0 {
maxAllowedPacket = *dumpConfig.MaxAllowedPacket
Expand Down Expand Up @@ -242,6 +251,8 @@ func dumpCmd(passedExecs execs, cmdConfig *cmdConfiguration) (*cobra.Command, er
PostBackupScripts: postBackupScripts,
SuppressUseDatabase: noDatabaseName,
Compact: compact,
Triggers: triggers,
Routines: routines,
MaxAllowedPacket: maxAllowedPacket,
Run: uid,
FilenamePattern: filenamePattern,
Expand Down Expand Up @@ -318,6 +329,9 @@ S3: If it is a URL of the format s3://bucketname/path then it will connect via S
// max-allowed-packet size
flags.Int("max-allowed-packet", defaultMaxAllowedPacket, "Maximum size of the buffer for client/server communication, similar to mysqldump's max_allowed_packet. 0 means to use the default size.")

// whether to include triggers and functions
flags.Bool("triggers-and-functions", false, "Whether to include triggers and functions in the dump.")

cmd.MarkFlagsMutuallyExclusive("once", "cron")
cmd.MarkFlagsMutuallyExclusive("once", "begin")
cmd.MarkFlagsMutuallyExclusive("once", "frequency")
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ The following are the environment variables, CLI flags and configuration file op
| SMB username, used only if a target does not have one | BRP | `smb-user` | `SMB_USER` | `dump.targets[smb-target].username` | |
| SMB password, used only if a target does not have one | BRP | `smb-pass` | `SMB_PASS` | `dump.targets[smb-target].password` | |
| compression to use, one of: `bzip2`, `gzip` | BP | `compression` | `DB_DUMP_COMPRESSION` | `dump.compression` | `gzip` |
| whether to include triggers, procedures and functions | B | `triggers-and-functions` | `DB_DUMP_TRIGGERS_AND_FUNCTIONS` | `dump.triggersAndFunctions` | `false` |
| when in container, run the dump or restore with `nice`/`ionice` | BR | `` | `NICE` | `` | `false` |
| filename to save the target backup file | B | `dump --filename-pattern` | `DB_DUMP_FILENAME_PATTERN` | `dump.filenamePattern` | |
| directory with scripts to execute before backup | B | `dump --pre-backup-scripts` | `DB_DUMP_PRE_BACKUP_SCRIPTS` | `dump.scripts.preBackup` | in container, `/scripts.d/pre-backup/` |
Expand Down Expand Up @@ -135,6 +136,7 @@ for details of each.
* `once`: run once and exit
* `compression`: the compression to use
* `compact`: compact the dump
* `triggersAndFunctions`: include triggers and functions and procedures in the dump
* `maxAllowedPacket`: max packet size
* `filenamePattern`: the filename pattern
* `scripts`:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
)

require (
github.com/databacker/api/go/api v0.0.0-20250418100420-12e1adda1303
github.com/databacker/api/go/api v0.0.0-20250423183243-7775066c265e
github.com/google/go-cmp v0.6.0
go.opentelemetry.io/otel v1.31.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ github.com/databacker/api/go/api v0.0.0-20250418091750-e67e3226ca5f h1:vuPsDEgli
github.com/databacker/api/go/api v0.0.0-20250418091750-e67e3226ca5f/go.mod h1:bQhbl71Lk1ATni0H+u249hjoQ8ShAdVNcNjnw6z+SbE=
github.com/databacker/api/go/api v0.0.0-20250418100420-12e1adda1303 h1:TVLyJzdvDvWIEs1/v6G0rQPpZeUsArQ7skzicjfCV8I=
github.com/databacker/api/go/api v0.0.0-20250418100420-12e1adda1303/go.mod h1:bQhbl71Lk1ATni0H+u249hjoQ8ShAdVNcNjnw6z+SbE=
github.com/databacker/api/go/api v0.0.0-20250423104730-2789787a240e h1:0ITg+YYAjyvM+rXirvZvx/PBLhMhHG+Nj5h+1flzWwY=
github.com/databacker/api/go/api v0.0.0-20250423104730-2789787a240e/go.mod h1:bQhbl71Lk1ATni0H+u249hjoQ8ShAdVNcNjnw6z+SbE=
github.com/databacker/api/go/api v0.0.0-20250423151229-1987d37f6e2f h1:JTyrIdH5lGiObGO7qFmON8ACIaCb5es+gjySkL/YWYc=
github.com/databacker/api/go/api v0.0.0-20250423151229-1987d37f6e2f/go.mod h1:bQhbl71Lk1ATni0H+u249hjoQ8ShAdVNcNjnw6z+SbE=
github.com/databacker/api/go/api v0.0.0-20250423183243-7775066c265e h1:5K7IbijS9p+dezx9m45CjFCR2Sf6BfT/tb540aEw66k=
github.com/databacker/api/go/api v0.0.0-20250423183243-7775066c265e/go.mod h1:bQhbl71Lk1ATni0H+u249hjoQ8ShAdVNcNjnw6z+SbE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
4 changes: 4 additions & 0 deletions pkg/core/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err
compressor := opts.Compressor
encryptor := opts.Encryptor
compact := opts.Compact
triggers := opts.Triggers
routines := opts.Routines
suppressUseDatabase := opts.SuppressUseDatabase
maxAllowedPacket := opts.MaxAllowedPacket
filenamePattern := opts.FilenamePattern
Expand Down Expand Up @@ -105,6 +107,8 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err
dbDumpCtx, dbDumpSpan := tracer.Start(ctx, "database_dump")
if err := database.Dump(dbDumpCtx, dbconn, database.DumpOpts{
Compact: compact,
Triggers: triggers,
Routines: routines,
SuppressUseDatabase: suppressUseDatabase,
MaxAllowedPacket: maxAllowedPacket,
}, dw); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/core/dumpoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type DumpOptions struct {
PreBackupScripts string
PostBackupScripts string
Compact bool
Triggers bool
Routines bool
SuppressUseDatabase bool
MaxAllowedPacket int
Run uuid.UUID
Expand Down
4 changes: 4 additions & 0 deletions pkg/database/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

type DumpOpts struct {
Compact bool
Triggers bool
Routines bool
SuppressUseDatabase bool
MaxAllowedPacket int
}
Expand All @@ -36,6 +38,8 @@ func Dump(ctx context.Context, dbconn Connection, opts DumpOpts, writers []DumpW
Schema: schema,
Host: dbconn.Host,
Compact: opts.Compact,
Triggers: opts.Triggers,
Routines: opts.Routines,
SuppressUseDatabase: opts.SuppressUseDatabase,
MaxAllowedPacket: opts.MaxAllowedPacket,
}
Expand Down
Loading