Add readme
This commit is contained in:
parent
fef951f0b4
commit
61f83bbd16
|
@ -0,0 +1,42 @@
|
|||
# Zero-Fuzz Docker Database Backup
|
||||
|
||||
A simple tool to create backup of all databases on a host. Supports postgres and mysql/mariadb.
|
||||
|
||||
Successor to [this script](https://kolaente.dev/konrad/docker-database-backup).
|
||||
|
||||
## Usage
|
||||
|
||||
Simply point it at your docker socket, mount a backup volume and be done:
|
||||
|
||||
```
|
||||
docker run -v $PWD:/backups -v /var/run/docker.sock:/var/run/docker.sock kolaente/db-backup
|
||||
```
|
||||
|
||||
The tool will find all database containers and create backups of them periodically. It will also discover new containers
|
||||
as they are started and won't try to back up containers which have gone away.
|
||||
|
||||
When running, all backups for the current run are time-stamped into a sub folder of the backup directory (see below).
|
||||
|
||||
## Config
|
||||
|
||||
All config is done with environment variables.
|
||||
|
||||
### `BACKUP_FOLDER`
|
||||
|
||||
Where all backup files will be stored.
|
||||
|
||||
Default: `/backups`
|
||||
|
||||
### `BACKUP_INTERVAL`
|
||||
|
||||
The interval at which backups will happen. Must be a parsable string
|
||||
as [time.Duration](https://pkg.go.dev/time#ParseDuration). Must be positive.
|
||||
|
||||
Default: `3h`
|
||||
|
||||
### `BACKUP_MAX`
|
||||
|
||||
How many backups to keep. If more backups are stored in the backup folder, the oldest one will be removed until there
|
||||
are only as many as this config variabls.
|
||||
|
||||
Default: `24`
|
10
config.go
10
config.go
|
@ -23,14 +23,20 @@ var (
|
|||
dumpTime time.Time
|
||||
)
|
||||
|
||||
const (
|
||||
envBackupFolder = `BACKUP_FOLDER`
|
||||
envInterval = `BACKUP_INTERVAL`
|
||||
envMax = `BACKUP_MAX`
|
||||
)
|
||||
|
||||
func init() {
|
||||
config = &conf{
|
||||
Folder: "/backups/",
|
||||
Interval: time.Hour * 6,
|
||||
MaxBackups: 12,
|
||||
MaxBackups: 24,
|
||||
}
|
||||
|
||||
folder, has := os.LookupEnv("BACKUP_FOLDER")
|
||||
folder, has := os.LookupEnv(envBackupFolder)
|
||||
if has {
|
||||
if !strings.HasSuffix(folder, "/") {
|
||||
folder = folder + "/"
|
||||
|
|
Loading…
Reference in New Issue