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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mysql-backup is a simple way to do MySQL database backups and restores, as well
It has the following features:

* dump and restore
* dump to local filesystem or to SMB server
* dump to supported targets
* select database user and password
* connect to any container running on the same system
* select how often to run a dump
Expand Down Expand Up @@ -96,7 +96,7 @@ __You should consider the [use of `--env-file=`](https://docs.docker.com/engine/
* `DB_PASS`: password for the database
* `DB_DUMP_INCLUDE`: names of databases to restore separated by spaces. Required if `SINGLE_DATABASE=true`.
* `SINGLE_DATABASE`: If is set to `true`, `DB_DUMP_INCLUDE` is required and must contain exactly one database name. Mysql command will then run with `--database=$DB_DUMP_INCLUDE` flag. This avoids the need of `USE <database>;` statement, which is useful when restoring from a file saved with `SINGLE_DATABASE` set to `true`.
* `DB_RESTORE_TARGET`: path to the actual restore file, which should be a compressed dump file. The target can be an absolute path, which should be volume mounted, an smb or S3 URL, similar to the target.
* `DB_RESTORE_TARGET`: path to the actual restore file, which should be a compressed dump file. The target can be any valid backup target.
* `DB_DEBUG`: if `true`, dump copious outputs to the container logs while restoring.
* To use the S3 driver `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_DEFAULT_REGION` will need to be defined.

Expand Down
18 changes: 17 additions & 1 deletion docs/backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ to a target. That target can be one of:
* local file
* SMB remote file
* S3 bucket
* SCP target

## Instructions and Examples for Backup Configuration Options

Expand Down Expand Up @@ -124,6 +125,7 @@ The value of the environment variable or CLI target can be one of three formats,
* Local: If it starts with a `/` character or `file:///` url, it will dump to a local path. If in a container, you should have it volume-mounted.
* SMB: If it is a URL of the format `smb://hostname/share/path/` then it will connect via SMB.
* S3: If it is a URL of the format `s3://bucketname.fqdn.com/path` then it will connect via using the S3 protocol.
* SCP: If it is a URL of the format `scp://user@hostname:/path` then it will connect via SCP.

In addition, you can send to multiple targets by separating them with a whitespace for the environment variable,
or native multiple options for other configuration options. For example, to send to a local directory and an SMB share:
Expand Down Expand Up @@ -190,7 +192,21 @@ Note that if you have multiple S3-compatible backup targets, each with its own s
or endpoint, then you _must_ use the config file. There is no way to distinguish between multiple sets of
credentials via the environment variables or CLI flags, while the config file provides credentials for each
target.


##### SCP

If it is a URL of the format `scp://user@hostname/path` then it will connect via SCP. If you leave off the `user`
i.e. `scp://hostname/path`, it will use the default ssh protocol for determining the user.
The default port is `22`; you can override it with `scp://hostname:port/path`.

The `scp` implementation respects the following configuration:

* user's ssh config file, by default `$HOME/.ssh/config`
* user's identity keys, by default `$HOME/.ssh/id_rsa`, `$HOME/.ssh/id_dsa`, etc.
* override the directory for finding `config` and identity key files via `SSH_HOME`

As of this writing, the SCP implementation is basic and may not support all features of the SCP protocol.

#### Configuration File

The configuration file is the most flexible way to configure the dump target. It allows you to specify
Expand Down
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/docker/go-connections v0.4.0
github.com/go-sql-driver/mysql v1.7.1
github.com/johannesboyne/gofakes3 v0.0.0-20230506070712-04da935ef877
github.com/moby/moby v28.3.3+incompatible
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
Expand All @@ -33,8 +32,12 @@ require (
require (
filippo.io/age v1.2.1
github.com/InfiniteLoopSpace/go_S-MIME v0.0.0-20181221134359-3f58f9a4b2b6
github.com/bramvdbogaerde/go-scp v1.5.0
github.com/databacker/api/go/api v0.0.0-20250818102239-219c793f2151
github.com/google/go-cmp v0.7.0
github.com/kevinburke/ssh_config v1.2.0
github.com/moby/go-archive v0.1.0
github.com/pkg/sftp v1.13.9
go.opentelemetry.io/otel v1.31.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0
Expand All @@ -43,17 +46,19 @@ require (
)

require (
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/gliderlabs/ssh v0.3.8 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/go-archive v0.1.0 // indirect
github.com/moby/sys/atomicwriter v0.1.0 // indirect
github.com/moby/sys/user v0.4.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
Expand Down
Loading