Skip to content

Docker MariaDB image with automatic backups.

License

Notifications You must be signed in to change notification settings

bfren/docker-mariadb

Repository files navigation

Docker MariaDB

GitHub release (latest by date) Docker Pulls Docker Image Size GitHub Workflow Status

Docker Repository - bfren ecosystem

MariaDB comes pre-installed (10.5, 10.6 LTS, 10.9, 10.10, 10.11 LTS, 11.0 and 11.1) with automatic backups built-in.

Contents

Automatic Backups

Backups for every database (except mysql, information_schema, performance_schema, and sys) are stored:

  • in the /var/lib/backup volume
  • in subfolders by date and time (yyMMddhhmm)
  • every eight hours

See For Backups for configuration variables.

It is strongly recommended that you run a backup before updating to a more recent version.

Ports

  • 3306

Volumes

Volume Purpose
/etc/my.cnf.d Optional additional mariadb configuration.
/var/lib/mysql Data files.
/var/lib/backup Backup files (also used for export / import scripts - see helper functions).

Environment Variables

For Backups

Variable Values Description Default
MARIADB_BACKUP_COMPRESS_FILES 0 or 1 Whether or not to compress backup files (using gzip). 0
MARIADB_BACKUP_KEEP_FOR_DAYS 0: keep forever
Num: days
How many days to keep backups before auto-deleting them. 14

For SSL

Variable Values Description Default
MARIADB_SSL_ENABLE 0 or 1 Set to "1" to enable SSL support. 0
MARIADB_SSL_DAYS integer The number of days before self-generated SSL certificates will expire. 3650 (ten years)
MARIADB_SSL_CA_KEY_BITS integer The size in bits of the CA SSL private key. 4096
MARIADB_SSL_SERVER_KEY_BITS integer The size in bits of the server SSL private key. 4096
MARIADB_SSL_CLIENT_KEY_BITS integer The size in bits of the client SSL private key. 4096

For Database

Variable Values Description Default
MARIADB_ROOT_PASSWORD string Password for root user. None - required
MARIADB_USERNAME string Application username - will be used as database name if MARIADB_DATABASE is not set. None - recommended
MARIADB_PASSWORD string Application password. None - required if username is defined
MARIADB_DATABASE string Database name(s) - multiple databases can be separated by a comma. None
MARIADB_CHARACTER_SET string Sets character_set_server. utf8
MARIADB_COLLATION string Sets collation_server. utf8_general_ci
MARIADB_LOG_WARNINGS string Sets log_warnings. 2

Helper Functions

Function Purpose Usage
db-backup Run backup manually. docker exec <<CONTAINER>> db-backup
db-export Dumps the specified database as a SQL file to the root of the /var/lib/backup volume. docker exec <<CONTAINER>> db-export <<DB_NAME>>
db-import Executes all files in the root of the /var/lib/backup volume. docker exec <<CONTAINER>> db-import

Licence

MIT

Copyright

Copyright (c) 2020-2023 bfren (unless otherwise stated)