├── .github ├── FUNDING.yml └── workflows │ ├── main.yml │ └── manual.yml ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── examples └── compose.yml ├── install ├── assets │ ├── defaults │ │ ├── 10-mariadb │ │ └── 20-mariadb-backup │ ├── functions │ │ ├── 10-mariadb │ │ └── 20-mariadb-backup │ └── mariadb │ │ ├── default.cnf │ │ └── standard.cnf ├── etc │ ├── cont-init.d │ │ ├── 10-mariadb │ │ └── 20-mariadb-backup │ ├── fluent-bit │ │ └── parsers.d │ │ │ └── mariadb.conf │ └── services.available │ │ ├── 10-mariadb │ │ └── run │ │ └── 20-mariadb-backup │ │ └── run └── usr │ └── local │ └── bin │ └── backup-now └── zabbix_templates ├── app_mariadb.json └── service_dbbackup.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [tiredofit] 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | ### Application Level Image CI 2 | ### Dave Conroy 3 | 4 | name: 'build' 5 | 6 | on: 7 | push: 8 | paths: 9 | - '**' 10 | - '!README.md' 11 | jobs: 12 | docker: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v2 17 | 18 | - name: Prepare 19 | id: prep 20 | run: | 21 | DOCKER_IMAGE=${GITHUB_REPOSITORY/docker-/} 22 | set -x 23 | if [[ $GITHUB_REF == refs/heads/* ]]; then 24 | if [[ $GITHUB_REF == refs/heads/*/* ]] ; then 25 | BRANCH="${DOCKER_IMAGE}:$(echo $GITHUB_REF | sed "s|refs/heads/||g" | sed "s|/|-|g")" 26 | else 27 | BRANCH=${GITHUB_REF#refs/heads/} 28 | fi 29 | 30 | case ${BRANCH} in 31 | "main" | "master" ) 32 | BRANCHTAG="${DOCKER_IMAGE}:latest" 33 | ;; 34 | "develop" ) 35 | BRANCHTAG="${DOCKER_IMAGE}:develop" 36 | ;; 37 | * ) 38 | if [ -n "${{ secrets.LATEST }}" ] ; then 39 | if [ "${BRANCHTAG}" = "${{ secrets.LATEST }}" ]; then 40 | BRANCHTAG="${DOCKER_IMAGE}:${BRANCH},${DOCKER_IMAGE}:${BRANCH}-latest,${DOCKER_IMAGE}:latest" 41 | else 42 | BRANCHTAG="${DOCKER_IMAGE}:${BRANCH},${DOCKER_IMAGE}:${BRANCH}-latest" 43 | fi 44 | else 45 | BRANCHTAG="${DOCKER_IMAGE}:${BRANCH},${DOCKER_IMAGE}:${BRANCH}-latest" 46 | fi 47 | ;; 48 | esac 49 | fi 50 | 51 | 52 | if [[ $GITHUB_REF == refs/tags/* ]]; then 53 | GITTAG="${DOCKER_IMAGE}:$(echo $GITHUB_REF | sed 's|refs/tags/||g')" 54 | fi 55 | 56 | if [ -n "${BRANCHTAG}" ] && [ -n "${GITTAG}" ]; then 57 | TAGS=${BRANCHTAG},${GITTAG} 58 | else 59 | TAGS="${BRANCHTAG}${GITTAG}" 60 | fi 61 | 62 | echo ::set-output name=tags::${TAGS} 63 | echo ::set-output name=docker_image::${DOCKER_IMAGE} 64 | 65 | - name: Set up QEMU 66 | uses: docker/setup-qemu-action@v1 67 | with: 68 | platforms: all 69 | 70 | - name: Set up Docker Buildx 71 | id: buildx 72 | uses: docker/setup-buildx-action@v1 73 | 74 | - name: Login to DockerHub 75 | if: github.event_name != 'pull_request' 76 | uses: docker/login-action@v1 77 | with: 78 | username: ${{ secrets.DOCKER_USERNAME }} 79 | password: ${{ secrets.DOCKER_PASSWORD }} 80 | 81 | - name: Label 82 | id: Label 83 | run: | 84 | if [ -f "Dockerfile" ] ; then 85 | sed -i "/FROM .*/a LABEL tiredofit.image.git_repository=\"https://github.com/${GITHUB_REPOSITORY}\"" Dockerfile 86 | sed -i "/FROM .*/a LABEL tiredofit.image.git_commit=\"${GITHUB_SHA}\"" Dockerfile 87 | sed -i "/FROM .*/a LABEL tiredofit.image.git_committed_by=\"${GITHUB_ACTOR}\"" Dockerfile 88 | sed -i "/FROM .*/a LABEL tiredofit.image.image_build_date=\"$(date +'%Y-%m-%d %H:%M:%S')\"" Dockerfile 89 | if [ -f "CHANGELOG.md" ] ; then 90 | sed -i "/FROM .*/a LABEL tiredofit.image.git_changelog_version=\"$(head -n1 ./CHANGELOG.md | awk '{print $2}')\"" Dockerfile 91 | mkdir -p install/assets/.changelogs ; cp CHANGELOG.md install/assets/.changelogs/${GITHUB_REPOSITORY/\//_}.md 92 | fi 93 | 94 | if [[ $GITHUB_REF == refs/tags/* ]]; then 95 | sed -i "/FROM .*/a LABEL tiredofit.image.git_tag=\"${GITHUB_REF#refs/tags/v}\"" Dockerfile 96 | fi 97 | 98 | if [[ $GITHUB_REF == refs/heads/* ]]; then 99 | sed -i "/FROM .*/a LABEL tiredofit.image.git_branch=\"${GITHUB_REF#refs/heads/}\"" Dockerfile 100 | fi 101 | fi 102 | 103 | - name: Build 104 | uses: docker/build-push-action@v2 105 | with: 106 | builder: ${{ steps.buildx.outputs.name }} 107 | context: . 108 | file: ./Dockerfile 109 | platforms: linux/amd64,linux/arm64 110 | push: true 111 | tags: ${{ steps.prep.outputs.tags }} 112 | -------------------------------------------------------------------------------- /.github/workflows/manual.yml: -------------------------------------------------------------------------------- 1 | # Manual Workflow (Application) 2 | 3 | name: manual 4 | 5 | on: 6 | workflow_dispatch: 7 | inputs: 8 | Manual Build: 9 | description: 'Manual Build' 10 | required: false 11 | jobs: 12 | docker: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v2 17 | 18 | - name: Prepare 19 | id: prep 20 | run: | 21 | DOCKER_IMAGE=${GITHUB_REPOSITORY/docker-/} 22 | set -x 23 | if [[ $GITHUB_REF == refs/heads/* ]]; then 24 | if [[ $GITHUB_REF == refs/heads/*/* ]] ; then 25 | BRANCH="${DOCKER_IMAGE}:$(echo $GITHUB_REF | sed "s|refs/heads/||g" | sed "s|/|-|g")" 26 | else 27 | BRANCH=${GITHUB_REF#refs/heads/} 28 | fi 29 | 30 | case ${BRANCH} in 31 | "main" | "master" ) 32 | BRANCHTAG="${DOCKER_IMAGE}:latest" 33 | ;; 34 | "develop" ) 35 | BRANCHTAG="${DOCKER_IMAGE}:develop" 36 | ;; 37 | * ) 38 | if [ -n "${{ secrets.LATEST }}" ] ; then 39 | if [ "${BRANCHTAG}" = "${{ secrets.LATEST }}" ]; then 40 | BRANCHTAG="${DOCKER_IMAGE}:${BRANCH},${DOCKER_IMAGE}:${BRANCH}-latest,${DOCKER_IMAGE}:latest" 41 | else 42 | BRANCHTAG="${DOCKER_IMAGE}:${BRANCH},${DOCKER_IMAGE}:${BRANCH}-latest" 43 | fi 44 | else 45 | BRANCHTAG="${DOCKER_IMAGE}:${BRANCH},${DOCKER_IMAGE}:${BRANCH}-latest" 46 | fi 47 | ;; 48 | esac 49 | fi 50 | 51 | 52 | if [[ $GITHUB_REF == refs/tags/* ]]; then 53 | GITTAG="${DOCKER_IMAGE}:$(echo $GITHUB_REF | sed 's|refs/tags/||g')" 54 | fi 55 | 56 | if [ -n "${BRANCHTAG}" ] && [ -n "${GITTAG}" ]; then 57 | TAGS=${BRANCHTAG},${GITTAG} 58 | else 59 | TAGS="${BRANCHTAG}${GITTAG}" 60 | fi 61 | 62 | echo ::set-output name=tags::${TAGS} 63 | echo ::set-output name=docker_image::${DOCKER_IMAGE} 64 | 65 | - name: Set up QEMU 66 | uses: docker/setup-qemu-action@v1 67 | with: 68 | platforms: all 69 | 70 | - name: Set up Docker Buildx 71 | id: buildx 72 | uses: docker/setup-buildx-action@v1 73 | 74 | - name: Login to DockerHub 75 | if: github.event_name != 'pull_request' 76 | uses: docker/login-action@v1 77 | with: 78 | username: ${{ secrets.DOCKER_USERNAME }} 79 | password: ${{ secrets.DOCKER_PASSWORD }} 80 | 81 | - name: Label 82 | id: Label 83 | run: | 84 | if [ -f "Dockerfile" ] ; then 85 | sed -i "/FROM .*/a LABEL tiredofit.image.git_repository=\"https://github.com/${GITHUB_REPOSITORY}\"" Dockerfile 86 | sed -i "/FROM .*/a LABEL tiredofit.image.git_commit=\"${GITHUB_SHA}\"" Dockerfile 87 | sed -i "/FROM .*/a LABEL tiredofit.image.git_committed_by=\"${GITHUB_ACTOR}\"" Dockerfile 88 | sed -i "/FROM .*/a LABEL tiredofit.image_build_date=\"$(date +'%Y-%m-%d %H:%M:%S')\"" Dockerfile 89 | if [ -f "CHANGELOG.md" ] ; then 90 | sed -i "/FROM .*/a LABEL tiredofit.image.git_changelog_version=\"$(head -n1 ./CHANGELOG.md | awk '{print $2}')\"" Dockerfile 91 | mkdir -p install/assets/.changelogs ; cp CHANGELOG.md install/assets/.changelogs/${GITHUB_REPOSITORY/\//_}.md 92 | fi 93 | 94 | if [[ $GITHUB_REF == refs/tags/* ]]; then 95 | sed -i "/FROM .*/a LABEL tiredofit.image.git_tag=\"${GITHUB_REF#refs/tags/v}\"" Dockerfile 96 | fi 97 | 98 | if [[ $GITHUB_REF == refs/heads/* ]]; then 99 | sed -i "/FROM .*/a LABEL tiredofit.image.git_branch=\"${GITHUB_REF#refs/heads/}\"" Dockerfile 100 | fi 101 | fi 102 | 103 | - name: Build 104 | uses: docker/build-push-action@v2 105 | with: 106 | builder: ${{ steps.buildx.outputs.name }} 107 | context: . 108 | file: ./Dockerfile 109 | platforms: linux/amd64 110 | push: true 111 | tags: ${{ steps.prep.outputs.tags }} 112 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 10.11-3.2.19 2025-05-22 2 | 3 | ### Added 4 | - MariaDB 10.11.13 5 | 6 | 7 | ## 10.11-3.2.18 2025-05-08 8 | 9 | ### Added 10 | - MariaDB 10.11.12 11 | - Pin to tiredofit/alpine:7.10.31 12 | 13 | 14 | ## 10.11-4.2.17 2025-02-04 15 | 16 | ### Added 17 | - Pin to tiredofit/alpine:3.20-7.10.27 18 | - MariaDB 10.11.11 19 | 20 | 21 | ## 10.11-4.2.16 2024-11-04 22 | 23 | ### Added 24 | - MariaDB 10.11.10 25 | - MySQLTuner 2.6.0 26 | - Pin to tiredofit/alpine:7.10.17 27 | 28 | 29 | ## 10.11-4.2.15 2024-08-14 30 | 31 | ### Added 32 | - MariaDB 10.11.9 33 | 34 | 35 | ## 10.11-4.2.14 2024-07-05 36 | 37 | ### Added 38 | - Alpine 3.20 base 39 | 40 | 41 | ## 10.11-4.2.13 2024-05-17 42 | 43 | ### Added 44 | - MariaDB 10.11.8 45 | 46 | 47 | ## 10.11-4.2.12 2024-02-08 48 | 49 | ### Added 50 | - MariaDB 10.11.7 51 | - MySQLTuner 2.5.2 52 | 53 | 54 | ## 10.11-4.2.11 2024-01-11 55 | 56 | All users are recommended to upgrade immediately to resolve a performance issue. 57 | 58 | ### Changed 59 | - Allow blobxfer package to be installed with Alpine 3.19 60 | - Properly read default environment variables when starting mariadb engine 61 | 62 | 63 | ## 10.11-4.2.10 2023-12-08 64 | 65 | ### Added 66 | - Change base image to tiredofit/alpine:3.19 67 | 68 | 69 | ## 10.11-4.2.9 2023-11-27 70 | 71 | ### Changed 72 | - Fix 4.2.8 to allow 127.0.01 and localhost concurrently 73 | - Fix issue where root password wasn't written properly 74 | 75 | 76 | ## 10.11-4.2.8 2023-11-23 77 | 78 | ### Changed 79 | - Change localhost permissions to 127.0.0.1 80 | 81 | 82 | ## 10.11-4.2.7 2023-11-20 83 | 84 | ### Changed 85 | - Fix issues with creating new databases on first install 86 | 87 | 88 | ## 10.11-4.2.6 2023-11-20 89 | 90 | ### Changed 91 | - Fix MariaDB startup routine 92 | 93 | 94 | ## 10.11-4.2.5 2023-11-14 95 | 96 | ### Added 97 | - armv8/aarch64 support 98 | - MySQL Tuner 2.2.12 99 | - MariaDB 10.11.6 100 | 101 | 102 | ## 10.11-4.2.4 2023-08-14 103 | 104 | ### Added 105 | - MariaDB 10.11.5 106 | 107 | 108 | ## 10.11-4.2.3 2023-06-07 109 | 110 | ### Added 111 | - MariaDB 10.11.4 112 | 113 | 114 | ## 10.11-4.2.2 2023-05-17 115 | 116 | ### Changed 117 | - Add additional failsafe GRANT statement for zbx_monitor access 118 | 119 | 120 | ## 10.11-4.2.1 2023-05-10 121 | 122 | ### Changed 123 | - Alpine 3.18 base 124 | 125 | 126 | ## 10.11-4.2.0 2023-04-26 127 | 128 | ### Added 129 | - Add support for _FILE environment variables 130 | 131 | 132 | ## 10.11-4.1.1 2023-04-12 133 | 134 | ### Added 135 | - Add additional FLUSH PRIVILEGES statement as a safety net when monitoring 136 | 137 | 138 | ## 4.1.0 2023-03-30 139 | 140 | ### Added 141 | - Add DB_BACKUP_CREATE_LATEST_SYMLINK for creating shortcuts to latest backup 142 | - Add DB_BACKUP_ARCHIVE_TIME and DB_BACKUP_DUMP_TARGET_ARCHIVE to move backups into archive folder after however many minutes for better external backups 143 | 144 | 145 | ## 10.11-4.0.2 2023-03-21 146 | 147 | ### Changed 148 | - Revert mariadb_autoreg to mariadb 149 | 150 | 151 | ## 10.11-4.0.1 2023-03-14 152 | 153 | ### Changed 154 | - Strip TCP check on mysql_upgrade 155 | - Change Autoregister to mariadbmodern 156 | - Remove IMAGE_NAME suffix 157 | 158 | 159 | ## 10.11-4.0.0 2023-02-08 160 | 161 | Major rewrite to the entire image bringing in a revamped way of dealing with multiple databases and users, bringing backup functionality up to parity with tiredofit/db-backup. Massive improvements with monitoring and safer initialization routines. 162 | Compatibility with older versions is possible, with the exception of DB Backup routines all being prefixed with DB_BACKUP_ 163 | 164 | ### Added 165 | - Pull MariaDB source instead of tarball, and compile in extra features 166 | - Switch to using bundled wolfSSL for TLS functions 167 | - Bring to parity with tiredofit/db-backup for in container backups 168 | - Zabbix Agent is now default and only supported way of doing metrics 169 | - Multiple Database Support + User support by means of DB01_,DB02,etc prefixes. Also allows for updating permissions and adding databases on subsequent reboots instead of on first initialization. 170 | - Make everything dynamic allowing for customization of configuration files, paths, data locations, socket locations. 171 | - Rework all initializations to work in a protected space before actually starting up the final mysqld process (Creating Databases/Users/Enabling Monitoring) 172 | - Monitoring is turnkey, user and password is automatically generated upon each container start to keep secrets from flying around 173 | - Modernize image with latest functions from tiredofit base images 174 | - Modernize Dockerfile to allow for cross distro compatibility 175 | - Further secure system by removing anonymous and extra users 176 | - Run as mariadb user, always, even when initializing 177 | - Rewrite Zabbix templates 178 | 179 | 180 | ## 3.12.4 2022-11-23 181 | 182 | ### Added 183 | - Alpine 3.17 Base 184 | 185 | 186 | ## 3.12.3 2022-10-19 187 | 188 | ### Changed 189 | - Fix for LOG_PATH environment variable 190 | 191 | 192 | ## 3.12.2 2022-10-19 193 | 194 | ### Changed 195 | - Fix for logrotate and logshipping not working properly 196 | 197 | 198 | ## 3.12.1 2022-10-03 199 | 200 | ### Added 201 | - Add LISTEN_PORT variable 202 | 203 | 204 | ## 3.12.0 2022-10-03 205 | 206 | ### Added 207 | - MariaDB 10.11.0 208 | 209 | 210 | ## 3.11.2 2022-10-02 211 | 212 | ### Changed 213 | - Patchup for 3.11.1 214 | 215 | 216 | ## 3.11.1 2022-10-02 217 | 218 | ### Changed 219 | - Patch for 3.11.0 220 | 221 | 222 | ## 3.11.0 2022-10-02 223 | 224 | ### Added 225 | - Add 60 seconds S6 Grace timeout to not destroy database writes and allow for safe shutdown 226 | - Increase verbosity with EXTRA_ARGUMENTS command 227 | 228 | ### Changed 229 | - Rework version upgrades, only execute on MAJOR version changes, yet still log minor release changes 230 | 231 | 232 | ## 3.10.21 2022-09-30 233 | 234 | ### Added 235 | - Add EXTRA_ARGUMENTS variable 236 | 237 | 238 | ## 3.10.20 2022-08-26 239 | 240 | ### Added 241 | - MariaDB 10.10.1 RC 242 | 243 | 244 | ## 3.10.19 2022-08-26 245 | 246 | ### Added 247 | - MariaDB 10.9.2 248 | 249 | 250 | ## 3.10.18 2022-08-26 251 | 252 | ### Added 253 | - MariaDB 10.8.4 254 | 255 | 256 | ## 3.10.17 2022-07-04 257 | 258 | ### Added 259 | - MySQLTuner 1.9.9 260 | 261 | 262 | ## 3.10.16 2022-06-21 263 | 264 | ### Changed 265 | - Zabbix Agent socket fix 266 | 267 | 268 | ## 3.10.15 2022-06-21 269 | 270 | ### Changed 271 | - Fix Image Name environment variable 272 | 273 | 274 | ## 3.10.14 2022-06-21 275 | 276 | ### Changed 277 | - Remove static Zabbix configuration 278 | 279 | 280 | ## 3.10.13 2022-06-21 281 | 282 | ### Changed 283 | - Fix for socket path and file 284 | 285 | 286 | ## 3.10.12 2022-06-18 287 | 288 | ### Added 289 | 290 | 291 | ## 3.10.11 2022-05-25 292 | 293 | ### Changed 294 | - Bugfix in Image name 295 | 296 | 297 | ## 3.10.10 2022-05-24 298 | 299 | ### Added 300 | - MariaDB 10.8.3 301 | 302 | 303 | ## 3.10.9 2022-05-24 304 | 305 | ### Added 306 | - MariaDB 10.7.4 307 | - Alpine 3.16 base 308 | 309 | 310 | ## 3.10.8 2022-04-06 311 | 312 | ### Added 313 | - Patchup for db-backup tmp state files 314 | 315 | 316 | ## 3.10.7 2022-03-04 317 | 318 | ### Added 319 | - Be more descriptive when we actually have to upgrade a database version 320 | 321 | 322 | ## 3.10.6 2022-02-14 323 | 324 | ### Added 325 | - MariaDB 10.6.7 326 | 327 | 328 | ## 3.10.5 2022-02-09 329 | 330 | ### Changed 331 | - Refresh base image 332 | 333 | 334 | ## 3.10.4 2021-12-13 335 | 336 | ### Changed 337 | - Prepare for Zabbix Agent 1/2 Switching 338 | 339 | 340 | ## 3.10.3 2021-12-07 341 | 342 | ### Added 343 | - Add Zabbix auto register support for templates 344 | 345 | 346 | ## 3.10.2 2021-11-24 347 | 348 | ### Added 349 | - Alpine 3.15 base 350 | 351 | ## 3.10.1 2021-11-08 352 | 353 | ### Added 354 | - MariaDB 10.6.5 355 | - MySQLtuner 1.8.3 356 | 357 | 358 | ## 3.10.0 2021-10-24 359 | 360 | ### Added 361 | - Switch to Alpine 3.14 as base and dont rely on Edge 362 | - Compile pixz instead of from packages 363 | 364 | 365 | ## 3.9.3 2021-09-04 366 | 367 | ### Changed 368 | - Change the way that logortate is configured for better parsing 369 | 370 | 371 | ## 3.9.2 2021-09-01 372 | 373 | ### Changed 374 | - Fix Regex 375 | 376 | 377 | ## 3.9.1 2021-09-01 378 | 379 | ### Changed 380 | - Modernize environment variables from upstream images 381 | 382 | 383 | ## 3.9.0 2021-08-30 384 | 385 | ### Added 386 | - Customizable logging support for error, general, and slow queries 387 | - Enabled logrotation for logs 388 | - Enabled fluent-bit log shipping parser for logs 389 | 390 | 391 | ## 3.8.1 2021-08-18 392 | 393 | ### Added 394 | - MariaDB 10.6.4 395 | 396 | 397 | ## 3.8.0 2021-07-25 398 | 399 | ### Added 400 | - MariaDB 10.6.3 401 | 402 | 403 | ## 3.7.5 2021-07-19 404 | 405 | ### Changed 406 | - Switch to classic Zabbix Agent for now 407 | 408 | 409 | ## 3.7.4 2021-07-12 410 | 411 | ### Added 412 | - MariaDB 10.5.11 413 | 414 | 415 | ## 3.7.3 2021-05-09 416 | 417 | ### Added 418 | - MariaDB 10.5.10 419 | 420 | 421 | ## 3.7.1 2021-03-18 422 | 423 | ### Added 424 | - MariaDB 10.5.9 425 | 426 | 427 | ## 3.7.0 2020-10-30 428 | 429 | ### Added 430 | - MariaDB 10.5.7 431 | 432 | ### Changed 433 | - Shellcheck fixes 434 | - CRLF fixes 435 | - Remove duplicate variables 436 | - Set defaults for mariadb-backup component 437 | - Remove old code and convert to new sanity_var / db_ready functions 438 | 439 | ## 3.6.4 2020-10-30 440 | 441 | ### Added 442 | - MariaDB 10.5.6 443 | 444 | 445 | ## 3.6.3 2020-09-17 446 | 447 | ### Changed 448 | - Remove false error when backing up manually 449 | 450 | 451 | ## 3.6.2 2020-09-17 452 | 453 | ### Changed 454 | - Fix MariaDB backup script `backup-now` 455 | 456 | 457 | ## 3.6.1 2020-08-26 458 | 459 | ### Added 460 | - MariaDB 10.5.5 461 | 462 | 463 | ## 3.6.0 2020-08-06 464 | 465 | ### Added 466 | - MariaDB 10.5.4 467 | 468 | 469 | ## 3.5.1 2020-07-03 470 | 471 | ### Changed 472 | - Cleanup code as per shellcheck warnings 473 | 474 | 475 | ## 3.5.0 2020-06-09 476 | 477 | ### Added 478 | - Update to support tiredofit/alpine 5.0.0 base image 479 | 480 | 481 | ## 3.4.4 2020-03-09 482 | 483 | ### Changed 484 | - Fix for container startup routines 485 | 486 | 487 | ## 3.4.3 2020-03-04 488 | 489 | ### Added 490 | - Update image to support new tiredofit/alpine:4.4.0 base 491 | 492 | 493 | ## 3.4.2 2020-02-24 494 | 495 | ### Added 496 | - MariaDB 10.4.12 497 | 498 | 499 | ## 3.4.1 2020-01-02 500 | 501 | ### Changed 502 | - Additional Changes to support new tiredofit/alpine base image 503 | 504 | 505 | ## 3.4.0 2019-12-29 506 | 507 | ### Added 508 | - Update to support new tiredofit/alpine image 509 | 510 | 511 | ## 3.3.6 2019-12-16 512 | 513 | ### Changed 514 | - Previous IMAGE_VERSION wasn't being populated on screen 515 | 516 | 517 | ## 3.3.5 2019-12-16 518 | 519 | ### Changed 520 | - Repair Auto Upgrade schema functionality 521 | 522 | 523 | ## 3.3.4 2019-12-15 524 | 525 | ### Changed 526 | - Switch to Alpine Edge due to missing proj/geos dependencies 527 | 528 | 529 | ## 3.3.3 2019-12-15 530 | 531 | ### Added 532 | - MariaDB 10.4.11 533 | 534 | 535 | ## 3.3.2 2019-11-18 536 | 537 | ### Changed 538 | - Change in execution of embedded backup script 539 | 540 | 541 | ## 3.3.1 2019-11-18 542 | 543 | ### Added 544 | - Update to MariaDB 10.4.10 545 | 546 | 547 | ## 3.3.0 2019-11-11 548 | 549 | * Added functionality to support scheduled backups within container (same functionality as tiredofit/mariadb-backup) 550 | 551 | ## 3.2.0 2019-11-05 552 | 553 | * MariaDB 10.4.8 554 | * Create DB Name with Charset and Default Collation 555 | * Auto Upgrade Check from earlier images 556 | * Renamed (but left compatibility) for Environment Variables 557 | * Added LZO and LZ4 compression capability 558 | * Included MySQL Tuner 559 | 560 | ## 3.1.2 2019-10-21 561 | 562 | * MariaDB 10.3.18 563 | 564 | ## 3.1.1 2019-06-30 565 | 566 | * Rename Proj4 to Proj 567 | 568 | ## 3.1 2019-06-19 569 | 570 | * Alpine 3.10 571 | 572 | ## 3.0.5 2019-06-19 573 | 574 | * MariaDB 10.3.16 575 | 576 | ## 3.0.4 2019-06-13 577 | 578 | * MariaDB 10.3.13 579 | 580 | ## 3.0.3 2019-02-08 581 | 582 | * Alpine 3.9 583 | * MariaDB 10.3.12 584 | 585 | ## 3.0.2 2018-12-10 586 | 587 | * MariaDB 10.3.11 588 | 589 | ## 3.0.1 2018-09-18 590 | 591 | * Fix bug with creating new database under mariadb username 592 | 593 | ## 3.0.0 2018-08-22 594 | 595 | * Maria DB 10.3.9 596 | * Ability to Create Multiple Databases 597 | 598 | ## 2.6.1 2018-08-22 599 | 600 | * Bump to MariaDB 10.2.17 601 | 602 | ## 2.6 2018-07-14 603 | 604 | * Allow setting default character set (default at moment is urf8) 605 | 606 | ## 2.51 2018-07-02 607 | 608 | * Bump to Alpine 3.8 609 | * MariaDB 10.2.16 610 | 611 | ## 2.5 2018-04-15 612 | 613 | * Bump to 10.2.14 614 | 615 | ## 2.4 2018-01-31 616 | 617 | * Bump to MariaDB 10.2.12 618 | * Alpine 3.7 Base 619 | * Tweak Zabbix Monitoring 620 | 621 | ## 2.3 2017-12-03 622 | 623 | * Update to MariaDB 10.2.11 624 | 625 | ## 2.2 2017-10-03 626 | 627 | * Update my.cnf permissions to 0644 628 | 629 | ## 2.1 2017-08-28 630 | 631 | * Image Reorganization 632 | * Tracking MariaDB release 10.2.8 633 | 634 | ## 2.0 2017-07-14 635 | 636 | * Rebase with S6 init.d 637 | * Alpine 3:4 base 638 | * Tracking MariaDB release 10.2.7 639 | 640 | ## 1.2 2017-05-19 641 | 642 | * Fixed Error in Dockerfile 643 | * MariaDB 10.2.3 644 | 645 | ## 1.1 2017-02-08 646 | 647 | * Rebase 648 | * Mysql 10.2.2 649 | 650 | ## 1.0 2017-02-08 651 | 652 | * Initial Release 653 | * Zabbix MySQL Monitoring Included 654 | * Tracking 10.1 Official Releases 655 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG DISTRO=alpine 2 | ARG DISTRO_VARIANT=3.20-7.10.30 3 | 4 | FROM docker.io/tiredofit/${DISTRO}:${DISTRO_VARIANT} 5 | LABEL maintainer="Dave Conroy (github.com/tiredofit)" 6 | 7 | ARG MARIADB_VERSION 8 | ARG MYSQLTUNER_VERSION 9 | 10 | ENV MARIADB_VERSION=${MARIADB_VERSION:-"10.11.13"} \ 11 | MYSQLTUNER_VERSION=${MYSQLTUNER_VERSION:-"v2.6.0"} \ 12 | MARIADB_REPO_URL=https://github.com/MariaDB/server \ 13 | MYSQLTUNER_REPO_URL=https://github.com/major/MySQLTuner-perl \ 14 | S6_SERVICES_GRACETIME=60000 \ 15 | CONTAINER_NAME=mariadb-db \ 16 | ZABBIX_AGENT_TYPE=modern \ 17 | CONTAINER_ENABLE_MESSAGING=FALSE \ 18 | CONTAINER_ENABLE_SCHEDULING=TRUE \ 19 | IMAGE_NAME="tiredofit/mariadb" \ 20 | IMAGE_REPO_URL="https://github.com/tiredofit/docker-mariadb/" 21 | 22 | ### Install Required Dependencies 23 | RUN source /assets/functions/00-container && \ 24 | set -x && \ 25 | package update && \ 26 | package upgrade && \ 27 | package install .mariadb-builddeps \ 28 | alpine-sdk \ 29 | asciidoc \ 30 | autoconf \ 31 | automake \ 32 | bison \ 33 | boost-dev \ 34 | bzip2-dev \ 35 | cmake \ 36 | curl-dev \ 37 | gnutls-dev \ 38 | libaio-dev \ 39 | libarchive-dev \ 40 | libevent-dev \ 41 | libxml2-dev \ 42 | linux-headers \ 43 | lz4-dev \ 44 | lzo-dev \ 45 | ncurses-dev \ 46 | pcre2-dev \ 47 | python3-dev \ 48 | py3-pip \ 49 | readline-dev \ 50 | xz-dev \ 51 | zlib-dev \ 52 | && \ 53 | \ 54 | package install .mariadb-rundeps \ 55 | aws-cli \ 56 | boost \ 57 | bzip2 \ 58 | geos \ 59 | gnutls \ 60 | ncurses-libs \ 61 | libaio \ 62 | libarchive \ 63 | libcurl \ 64 | lzo \ 65 | lz4 \ 66 | lz4-libs \ 67 | libstdc++ \ 68 | libxml2 \ 69 | perl \ 70 | perl-doc \ 71 | pigz \ 72 | proj \ 73 | pwgen \ 74 | py3-cryptography \ 75 | xz \ 76 | zstd \ 77 | && \ 78 | \ 79 | pip3 install --break-system-packages blobxfer && \ 80 | \ 81 | addgroup -S -g 3306 mariadb && \ 82 | adduser -S -D -H -u 3306 -G mariadb -g "MariaDB" mariadb && \ 83 | \ 84 | clone_git_repo "${MARIADB_REPO_URL}" "mariadb-${MARIADB_VERSION}" && \ 85 | sed -i 's/END()/ENDIF()/' libmariadb/cmake/ConnectorName.cmake && \ 86 | mkdir -p /tmp/_ && \ 87 | cmake . \ 88 | -DCMAKE_BUILD_TYPE=MinSizeRel \ 89 | -DCOMMON_C_FLAGS="-O3 -s -fno-omit-frame-pointer -pipe" \ 90 | -DCOMMON_CXX_FLAGS="-O3 -s -fno-omit-frame-pointer -pipe" \ 91 | -DCMAKE_INSTALL_PREFIX=/usr \ 92 | -DSYSCONFDIR=/etc/mysql \ 93 | -DMYSQL_DATADIR=/var/lib/mysql \ 94 | -DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock \ 95 | -DDEFAULT_CHARSET=utf8mb4 \ 96 | -DDEFAULT_COLLATION=utf8mb4_general_ci \ 97 | -DINSTALL_INFODIR=share/mysql/docs \ 98 | -DINSTALL_MANDIR=/tmp/_/share/man \ 99 | -DINSTALL_PLUGINDIR=lib/mysql/plugin \ 100 | -DINSTALL_SCRIPTDIR=bin \ 101 | -DINSTALL_DOCREADMEDIR=/tmp/_/share/mysql \ 102 | -DINSTALL_SUPPORTFILESDIR=share/mysql \ 103 | -DINSTALL_MYSQLSHAREDIR=share/mysql \ 104 | -DINSTALL_DOCDIR=/tmp/_/share/mysql/docs \ 105 | -DINSTALL_SHAREDIR=share/mysql \ 106 | -DCONNECT_WITH_MYSQL=ON \ 107 | -DCONNECT_WITH_LIBXML2=system \ 108 | -DCONNECT_WITH_ODBC=NO \ 109 | -DCONNECT_WITH_JDBC=NO \ 110 | -DENABLED_PROFILING=OFF \ 111 | -DENABLED_LOCAL_INFILE=ON \ 112 | -DENABLE_DEBUG_SYNC=OFF \ 113 | -DPLUGIN_ARCHIVE=YES \ 114 | -DPLUGIN_ARIA=YES \ 115 | -DPLUGIN_AUTH_GSSAPI=NO \ 116 | -DPLUGIN_AUTH_GSSAPI_CLIENT=OFF \ 117 | -DPLUGIN_BLACKHOLE=YES \ 118 | -DPLUGIN_CASSANDRA=NO \ 119 | -DPLUGIN_CONNECT=NO \ 120 | -DPLUGIN_CRACKLIB_PASSWORD_CHECK=NO \ 121 | -DPLUGIN_CSV=YES \ 122 | -DPLUGIN_FEDERATED=NO \ 123 | -DPLUGIN_FEDERATEDX=NO \ 124 | -DPLUGIN_FEEDBACK=NO \ 125 | -DPLUGIN_INNOBASE=STATIC \ 126 | -DPLUGIN_MROONGA=NO \ 127 | -DPLUGIN_MYISAM=YES \ 128 | -DPLUGIN_OQGRAPH=NO \ 129 | -DPLUGIN_PARTITION=AUTO \ 130 | -DPLUGIN_ROCKSDB=NO \ 131 | -DPLUGIN_SPHINX=NO \ 132 | -DPLUGIN_TOKUDB=NO \ 133 | -DWITH_ASAN=OFF \ 134 | -DWITH_EMBEDDED_SERVER=OFF \ 135 | -DWITH_EXTRA_CHARSETS=complex \ 136 | -DWITH_INNODB_BZIP2=OFF \ 137 | -DWITH_INNODB_LZ4=OFF \ 138 | -DWITH_INNODB_LZMA=ON \ 139 | -DWITH_INNODB_LZO=OFF \ 140 | -DWITH_INNODB_SNAPPY=OFF \ 141 | -DWITH_JEMALLOC=NO \ 142 | -DWITH_LIBARCHIVE=system \ 143 | -DWITH_LIBNUMA=NO \ 144 | -DWITH_LIBWRAP=OFF \ 145 | -DWITH_LIBWSEP=OFF \ 146 | -DWITH_MARIABACKUP=ON \ 147 | -DWITH_PCRE=system \ 148 | -DWITH_READLINE=ON \ 149 | -DWITH_ROCKSDB_BZIP2=OFF \ 150 | -DWITH_ROCKSDB_JEMALLOC=OFF \ 151 | -DWITH_ROCKSDB_LZ4=OFF \ 152 | -DWITH_ROCKSDB_SNAPPY=OFF \ 153 | -DWITH_ROCKSDB_ZSTD=OFF \ 154 | -DWITH_SSL=bundled \ 155 | -DWITH_SYSTEMD=no \ 156 | -DWITH_UNIT_TESTS=OFF \ 157 | -DWITH_VALGRIND=OFF \ 158 | -DWITH_ZLIB=system \ 159 | -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ 160 | -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 \ 161 | -DWITHOUT_PBXT_STORAGE_ENGINE=1 \ 162 | && \ 163 | \ 164 | make -j$(getconf _NPROCESSORS_ONLN) && \ 165 | make install && \ 166 | \ 167 | # Patch for missing PAM Plugin 168 | #sed -i 's/^.*auth_pam_tool_dir.*$/#auth_pam_tool_dir not exists/' /usr/bin/mysql_install_db && \ 169 | \ 170 | ### Fetch and Install MySQLTuner 171 | clone_git_repo "${MYSQLTUNER_REPO_URL}" "${MYSQLTUNER_VERSION}" && \ 172 | mkdir -p /usr/share/mysqltuner && \ 173 | cp -R basic_passwords.txt /usr/share/mysqltuner && \ 174 | cp -R vulnerabilities.csv /usr/share/mysqltuner && \ 175 | mv mysqltuner.pl /usr/sbin/mysqltuner && \ 176 | chmod +x /usr/sbin/mysqltuner && \ 177 | \ 178 | ### Fetch and install parallel PBZip2 179 | mkdir -p /usr/src/pbzip2 && \ 180 | curl -ssL https://launchpad.net/pbzip2/1.1/1.1.13/+download/pbzip2-1.1.13.tar.gz | tar xvfz - --strip=1 -C /usr/src/pbzip2 && \ 181 | cd /usr/src/pbzip2 && \ 182 | make -j$(getconf _NPROCESSORS_ONLN) && \ 183 | make install && \ 184 | strip /usr/bin/pbzip2 && \ 185 | \ 186 | # Fetch and compile pixz 187 | clone_git_repo "https://github.com/vasi/pixz" && \ 188 | ./autogen.sh && \ 189 | ./configure && \ 190 | make -j$(getconf _NPROCESSORS_ONLN) && \ 191 | make install && \ 192 | strip /usr/local/bin/pixz && \ 193 | \ 194 | package remove .mariadb-builddeps && \ 195 | package cleanup && \ 196 | \ 197 | rm -rf \ 198 | /root/.cache \ 199 | /tmp/* \ 200 | /usr/bin/mysql_client_test \ 201 | /usr/bin/mysqltest \ 202 | /usr/data \ 203 | /usr/mysql-test \ 204 | /usr/sql-bench \ 205 | /usr/src/* 206 | 207 | EXPOSE 3306 208 | 209 | COPY install / 210 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2023 Dave Conroy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # github.com/tiredofit/docker-mariadb 2 | 3 | [![GitHub release](https://img.shields.io/github/v/tag/tiredofit/docker-mariadb?style=flat-square)](https://github.com/tiredofit/docker-mariadb/releases/latest) 4 | [![Build Status](https://img.shields.io/github/actions/workflow/status/tiredofit/docker-mariadb/main.yml?branch=10.6&style=flat-square)](https://github.com/tiredofit/docker-mariadb/actions) 5 | [![Docker Stars](https://img.shields.io/docker/stars/tiredofit/mariadb.svg?style=flat-square&logo=docker)](https://hub.docker.com/r/tiredofit/mariadb/) 6 | [![Docker Pulls](https://img.shields.io/docker/pulls/tiredofit/mariadb.svg?style=flat-square&logo=docker)](https://hub.docker.com/r/tiredofit/mariadb/) 7 | [![Become a sponsor](https://img.shields.io/badge/sponsor-tiredofit-181717.svg?logo=github&style=flat-square)](https://github.com/sponsors/tiredofit) 8 | [![Paypal Donate](https://img.shields.io/badge/donate-paypal-00457c.svg?logo=paypal&style=flat-square)](https://www.paypal.me/tiredofit) 9 | 10 | ## About 11 | 12 | This will build a Docker image for [MariaDB](https://mariadb.org). A relational database forked from MySQL. 13 | 14 | * Configuration tweaked to use all around settings for general usage - Can be changed 15 | * Can use official Mysql/MariaDB environment variables (MYSQL_USER, MYSQL_PASSWORD, MYSQL_ROOT_PASSWORD) 16 | * Allows for automatically creating multiple databases on container initialization and subsequent reboots 17 | * Automatic Table/DB Upgrade support if MariaDB version has changed 18 | * Includes MySQL Tuner inside image to optimize your configuration 19 | * Logging with automatic rotation 20 | * Zabbix Monitoring for metrics 21 | 22 | Also has the capability of backing up embedded in the container based on the [tiredofit/dbbackup](https://github.com/tiredofit/docker-db-backup) image which includes the following features: 23 | 24 | * dump to local filesystem 25 | * Backup all databases 26 | * choose to have an MD5?SHA sum after backup for verification 27 | * delete old backups after specific amount of time 28 | * choose compression type (none, gz, bz, xz,zstd) 29 | * select how often to run a dump 30 | * select when to start the first dump, whether time of day or relative to container start time 31 | 32 | ## Maintainer 33 | 34 | - [Dave Conroy](https://github.com/tiredofit) 35 | 36 | ## Table of Contents 37 | 38 | - [About](#about) 39 | - [Maintainer](#maintainer) 40 | - [Table of Contents](#table-of-contents) 41 | - [Installation](#installation) 42 | - [Build from Source](#build-from-source) 43 | - [Prebuilt Images](#prebuilt-images) 44 | - [Multi Architecture](#multi-architecture) 45 | - [Configuration](#configuration) 46 | - [Quick Start](#quick-start) 47 | - [Persistent Storage](#persistent-storage) 48 | - [Environment Variables](#environment-variables) 49 | - [Base Images used](#base-images-used) 50 | - [Container Options](#container-options) 51 | - [MariaDB Options](#mariadb-options) 52 | - [Database Options](#database-options) 53 | - [Logging Options](#logging-options) 54 | - [Backup Options](#backup-options) 55 | - [Database Options](#database-options-1) 56 | - [Scheduling Options](#scheduling-options) 57 | - [Other Backup Options](#other-backup-options) 58 | - [Backing Up to S3 Compatible Services](#backing-up-to-s3-compatible-services) 59 | - [Upload to a Azure storage account by `blobxfer`](#upload-to-a-azure-storage-account-by-blobxfer) 60 | - [Networking](#networking) 61 | - [Maintenance](#maintenance) 62 | - [Shell Access](#shell-access) 63 | - [Mysql Tuner](#mysql-tuner) 64 | - [Manual Backups](#manual-backups) 65 | - [Contributions](#contributions) 66 | - [Support](#support) 67 | - [Usage](#usage) 68 | - [Bugfixes](#bugfixes) 69 | - [Feature Requests](#feature-requests) 70 | - [Updates](#updates) 71 | - [License](#license) 72 | - [References](#references) 73 | 74 | ## Installation 75 | 76 | ### Build from Source 77 | Clone this repository and build the image with `docker build (imagename) .` 78 | ### Prebuilt Images 79 | Builds of the image are available on [Docker Hub](https://hub.docker.com/r/tiredofit/mariadb) 80 | 81 | ```bash 82 | docker pull docker.io/tiredofdit/mariadb:(imagetag) 83 | ``` 84 | 85 | Builds of the image are also available on the [Github Container Registry](https://github.com/tiredofit/docker-mariadb/pkgs/container/docker-mariadb) 86 | 87 | ``` 88 | docker pull ghcr.io/tiredofit/docker-mariadb:(imagetag) 89 | ``` 90 | 91 | The following image tags are available along with their tagged release based on what's written in the [Changelog](CHANGELOG.md): 92 | 93 | | Version | Container OS | Tag | 94 | | --------- | ------------ | --------- | 95 | | latest | Alpine | `:latest` | 96 | | `10.11.x` | Alpine | `:10.11` | 97 | | `10.10.x` | Alpine | `:10.10` | 98 | | `10.9.x` | Alpine | `:10.9` | 99 | | `10.8.x` | Alpine | `:10.8` | 100 | | `10.6.x` | Alpine | `:10.6` | 101 | | `10.5.x` | Alpine | `:10.5` | 102 | 103 | #### Multi Architecture 104 | Images are built primarily for `amd64` architecture, and may also include builds for `arm/v7`, `arm64` and others. These variants are all unsupported. Consider [sponsoring](https://github.com/sponsors/tiredofit) my work so that I can work with various hardware. To see if this image supports multiple architecures, type `docker manifest (image):(tag)` 105 | 106 | ## Configuration 107 | 108 | ### Quick Start 109 | 110 | * The quickest way to get started is using [docker-compose](https://docs.docker.com/compose/). See the examples folder for a working [compose.yml](examples/compose.yml) that can be modified for development or production use. 111 | 112 | * Set various [environment variables](#environment-variables) to understand the capabilities of this image. 113 | * Map [persistent storage](#data-volumes) for access to configuration and data files for backup. 114 | - Make [networking ports](#networking) available for public access if necessary 115 | 116 | ### Persistent Storage 117 | 118 | The following directories are used for configuration and can be mapped for persistent storage. 119 | 120 | | Directory | Description | 121 | | ------------------- | -------------------------------------------------------------- | 122 | | `/var/lib/mysql` | MySQL Data Directory | 123 | | `/etc/mysql/conf.d` | Optional directory to put .cnf files for additional directives | 124 | | `/backup` | Optional directory for backups | 125 | 126 | ### Environment Variables 127 | 128 | #### Base Images used 129 | 130 | This image relies on an [Alpine Linux](https://hub.docker.com/r/tiredofit/alpine) base image that relies on an [init system](https://github.com/just-containers/s6-overlay) for added capabilities. Outgoing SMTP capabilities are handlded via `msmtp`. Individual container performance monitoring is performed by [zabbix-agent](https://zabbix.org). Additional tools include: `bash`,`curl`,`less`,`logrotate`,`nano`,`vim`. 131 | 132 | Be sure to view the following repositories to understand all the customizable options: 133 | 134 | | Image | Description | 135 | | ------------------------------------------------------ | -------------------------------------- | 136 | | [OS Base](https://github.com/tiredofit/docker-alpine/) | Customized Image based on Alpine Linux | 137 | 138 | #### Container Options 139 | | Parameter | Description | Default | 140 | | -------------------- | ------------------------------------------------- | ----------------------- | 141 | | `CERT_PATH` | Certs Path | | 142 | | `CONFIG_FILE` | Configuration File to load - Not needed to be set | `my.cnf` | 143 | | `CONFIG_PATH` | Configuration Path | `/etc/mysql/` | 144 | | `CONFIG_CUSTOM_PATH` | Configuration Override Path | `${CONFIG_PATH}/conf.d` | 145 | | `DATA_PATH` | Data Files Path | `/var/lib/mysql/` | 146 | | `LOG_PATH` | Log Files Path | `/logs/` | 147 | | `SOCKET_FILE` | Socket Name | `mysqld.sock` | 148 | | `SOCKET_PATH` | Socket Path | `/run/mysqld/` | 149 | 150 | #### MariaDB Options 151 | 152 | | Parameter | Description | Default | `_FILE` | 153 | | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------- | 154 | | `CHARACTER_SET` | Set Default Character Set | `utf8mb4` | | 155 | | `COLLATION` | Set Default Collation | `utf8mb4_general_ci` | | 156 | | `DB_AUTO_UPGRADE` | If MariaDB has changed from first time image has been used, automatically upgrade DBs and tables to latest versions - `TRUE` / `FALSE` | `TRUE` | | 157 | | `DB_CONFIGURATION` | Type of Configuration - `standard`, or `default` | `standard` | | 158 | | `LISTEN_PORT` | Listening Port | `3306` | | 159 | | `ROOT_PASS` | Root Password for Instance (e.g. password) | | x | 160 | | `MYSQLD_ARGS` | Add extra arguments to the mariadb execution | | | 161 | 162 | * With regards to `DB_CONFIGURATION` 163 | - `default` - Means the default my.cnf file from MariaDB 164 | - `standard` - My own settings that I find work for my own DB servers. 165 | 166 | #### Database Options 167 | 168 | Automatically create user databases on startup. This can be done on each container start, and then removed on subsequent starts if desired. 169 | 170 | | Parameter | Description | Default | `_FILE` | 171 | | ----------- | ----------------------------------------- | ------- | ------- | 172 | | `CREATE_DB` | Automatically create databases on startup | `TRUE` | | 173 | | `DB_NAME` | Database Name e.g. `database` | | x | 174 | | `DB_USER` | Database User e.g. `user` | | x | 175 | | `DB_PASS` | Database Pass e.g. `password` | | x | 176 | 177 | **OR** 178 | 179 | Create multiple databases and different usernames and passwords to access. You can share usernames and passwords for multiple databases by using the same user and password in each entry. 180 | 181 | | Parameter | Description | Default | `_FILE` | 182 | | ----------- | -------------------------------------------------- | ------- | ------- | 183 | | `DB01_NAME` | First Database Name e.g. `database1` | | x | 184 | | `DB01_USER` | First Database User e.g. `user1` | | x | 185 | | `DB01_PASS` | First Database Pass e.g. `password1` | | x | 186 | | `DB02_NAME` | Second Database Name e.g. `database1` | | x | 187 | | `DB02_USER` | Second Database User e.g. `user2` | | x | 188 | | `DB02_PASS` | Second Database Pass e.g. `password2` | | x | 189 | | `DBXX_...` | As above, should be able to go all the way to `99` | | | 190 | 191 | 192 | #### Logging Options 193 | 194 | | Parameter | Description | Default | 195 | | -------------------------- | ------------------------------------------------------------ | ---------------- | 196 | | `ENABLE_LOG_ERROR` | Enable Error Logging | `TRUE` | 197 | | `ENABLE_LOG_GENERAL_QUERY` | Log all connections and queries to server (performance hit!) | `FALSE` | 198 | | `ENABLE_SLOW_QUERY_LOG` | Log all slow queries | `FALSE` | 199 | | `LOG_PATH` | Path where logs are stored | `/logs/` | 200 | | `LOG_FILE_ERROR` | Error Log File Name | `error.log` | 201 | | `LOG_FILE_GENERAL_QUERY` | General Query Log File name | `general.log` | 202 | | `LOG_FILE_SLOW_QUERY` | Slow Query Log File Name | `slow_query.log` | 203 | | `LOG_LEVEL` | Log Level for warnings `0` to `9` | `3` | 204 | 205 | 206 | #### Backup Options 207 | The backup functionality is a subset of the [tiredofit/db-backup](https://github.com/tiredofit/docker-db-backup) image. Please have a peek at the README to understand ways to use. All features have been carried over with the exception of being able to backup remote systems - It is hardcoded to connect to the MariaDB socket not requiring DB_HOST/DB_PORT variables. 208 | 209 | 210 | | Parameter | Description | Default | 211 | | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------- | 212 | | `DB_BACKUP_BACKUP_LOCATION` | Backup to `FILESYSTEM` or `S3` compatible services like S3, Minio, Wasabi | `FILESYSTEM` | 213 | | `DB_BACKUP_MODE` | `AUTO` mode to use internal scheduling routines or `MANUAL` to simply use this as manual backups only executed by your own means | `AUTO` | 214 | | `DB_BACKUP_MANUAL_RUN_FOREVER` | `TRUE` or `FALSE` if you wish to try to make the container exit after the backup | `TRUE` | 215 | | `DB_BACKUP_TEMP_LOCATION` | Perform Backups and Compression in this temporary directory | `/tmp/backups/` | 216 | | `DB_BACKUP_CREATE_LATEST_SYMLINK` | Create a symbolic link pointing to last backup in this format: `latest-(DB_TYPE)-(DB_NAME)-(DB_HOST)` | `TRUE` | 217 | | `DEBUG_MODE` | If set to `true`, print copious shell script messages to the container log. Otherwise only basic messages are printed. | `FALSE` | 218 | | `DB_BACKUP_PRE_SCRIPT` | Fill this variable in with a command to execute pre backing up | | 219 | | `DB_BACKUP_POST_SCRIPT` | Fill this variable in with a command to execute post backing up | | 220 | | `DB_BACKUP_SPLIT_DB` | For each backup, create a new archive. `TRUE` or `FALSE` (MySQL and Postgresql Only) | `TRUE` | 221 | 222 | ##### Database Options 223 | | Parameter | Description | Default | `_FILE` | 224 | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------- | 225 | | `DB_BACKUP_NAME` | Schema Name e.g. `database` or `ALL` to backup all databases the user has access to. Backup multiple by seperating with commas eg `db1,db2` | | | 226 | | `DB_BACKUP_NAME_EXCLUDE` | If using `ALL` - use this as to exclude databases seperated via commas from being backed up | | | 227 | | `DB_BACKUP_USER` | username for the database(s) - Can use `root` | | x| 228 | | `DB_BACKUP_PASS` | (optional if DB doesn't require it) password for the database | | x| 229 | 230 | ##### Scheduling Options 231 | | Parameter | Description | Default | 232 | | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | 233 | | `DB_BACKUP_DUMP_FREQ` | How often to do a dump, in minutes after the first backup. Defaults to 1440 minutes, or once per day. | `1440` | 234 | | `DB_BACKUP_DUMP_BEGIN` | What time to do the first dump. Defaults to immediate. Must be in one of two formats | | 235 | | | Absolute HHMM, e.g. `2330` or `0415` | | 236 | | | Relative +MM, i.e. how many minutes after starting the container, e.g. `+0` (immediate), `+10` (in 10 minutes), or `+90` in an hour and a half | | 237 | | `DB_BACKUP_DUMP_TARGET` | Directory where the database dumps are kept. | `/backup` | 238 | | `DB_BACKUP_DUMP_TARGET_ARCHIVE` | Optional Directory where the database dumps archives are kept. | 239 | | `DB_BACKUP_CLEANUP_TIME` | Value in minutes to delete old backups (only fired when dump freqency fires). 1440 would delete anything above 1 day old. You don't need to set this variable if you want to hold onto everything. | `FALSE` | 240 | | `DB_ARCHIVE_TIME` | Value in minutes to move all files files older than (x) from `DB_BACKUP_DUMP_TARGET` to `DB_BACKUP_DUMP_TARGET_ARCHIVE` - which is useful when pairing against an external backup system. | 241 | 242 | ##### Other Backup Options 243 | | Parameter | Description | Default | 244 | | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------- | 245 | | `DB_BACKUP_COMPRESSION` | Use either Gzip `GZ`, Bzip2 `BZ`, XZip `XZ`, ZSTD `ZSTD` or none `NONE` | `ZSTD` | 246 | | `DB_BACKUP_COMPRESSION_LEVEL` | Numberical value of what level of compression to use, most allow `1` to `9` except for `ZSTD` which allows for `1` to `19` - | `3` | 247 | | `DB_BACKUP_ENABLE_PARALLEL_COMPRESSION` | Use multiple cores when compressing backups `TRUE` or `FALSE` | `TRUE` | 248 | | `DB_BACKUP_PARALLEL_COMPRESSION_THREADS` | Maximum amount of threads to use when compressing - Integer value e.g. `8` | `autodetected` | 249 | | `DB_BACKUP_GZ_RSYNCABLE` | Use `--rsyncable` (gzip only) for faster rsync transfers and incremental backup deduplication. e.g. `TRUE` | `FALSE` | 250 | | `DB_BACKUP_ENABLE_CHECKSUM` | Generate either a MD5 or SHA1 in Directory, `TRUE` or `FALSE` | `TRUE` | 251 | | `DB_BACKUP_CHECKSUM` | Either `MD5` or `SHA1` | `MD5` | 252 | | `DB_BACKUP_EXTRA_OPTS` | If you need to pass extra arguments to the backup command, add them here e.g. `--extra-command` | | 253 | 254 | #### Backing Up to S3 Compatible Services 255 | 256 | If `DB_BACKUP_LOCATION` = `S3` then the following options are used. 257 | 258 | | Parameter | Description | Default | `_FILE` | 259 | | ------------------------------- | ----------------------------------------------------------------------------------------- | ------- | ---- | 260 | | `DB_BACKUP_S3_BUCKET` | S3 Bucket name e.g. `mybucket` | | x | 261 | | `DB_BACKUP_S3_KEY_ID` | S3 Key ID (Optional) | | x | 262 | | `DB_BACKUP_S3_KEY_SECRET` | S3 Key Secret (Optional) | | x | 263 | | `DB_BACKUP_S3_PATH` | S3 Pathname to save to (must NOT end in a trailing slash e.g. '`backup`') | | x | 264 | | `DB_BACKUP_S3_REGION` | Define region in which bucket is defined. Example: `ap-northeast-2` | | x | 265 | | `DB_BACKUP_S3_HOST` | Hostname (and port) of S3-compatible service, e.g. `minio:8080`. Defaults to AWS. | | x | 266 | | `DB_BACKUP_S3_PROTOCOL` | Protocol to connect to `S3_HOST`. Either `http` or `https`. Defaults to `https`. | `https` | x | 267 | | `DB_BACKUP_S3_EXTRA_OPTS` | Add any extra options to the end of the `aws-cli` process execution | | x | 268 | | `DB_BACKUP_S3_CERT_CA_FILE` | Map a volume and point to your custom CA Bundle for verification e.g. `/certs/bundle.pem` | | x | 269 | | _*OR*_ | | | | 270 | | `DB_BACKUP_S3_CERT_SKIP_VERIFY` | Skip verifying self signed certificates when connecting | `TRUE` | | 271 | 272 | - When `DB_BACKUP_S3_KEY_ID` and/or `DB_BACKUP_S3_KEY_SECRET` is not set, will try to use IAM role assigned (if any) for uploading the backup files to S3 bucket. 273 | 274 | #### Upload to a Azure storage account by `blobxfer` 275 | 276 | Support to upload backup files with [blobxfer](https://github.com/Azure/blobxfer) to the Azure fileshare storage. 277 | 278 | 279 | If `DB_BACKUP_BACKUP_LOCATION` = `blobxfer` then the following options are used. 280 | 281 | | Parameter | Description | Default | `_FILE` | 282 | | ---------------------------------------- | ------------------------------------------- | ------------------- | ------- | 283 | | `DB_BACKUP_BLOBXFER_STORAGE_ACCOUNT` | Microsoft Azure Cloud storage account name. | | x| 284 | | `DB_BACKUP_BLOBXFER_STORAGE_ACCOUNT_KEY` | Microsoft Azure Cloud storage account key. | | x| 285 | | `DB_BACKUP_BLOBXFER_REMOTE_PATH` | Remote Azure path | `/docker-db-backup` | | 286 | 287 | > This service uploads files from backup targed directory `DB_BACKUP_DUMP_TARGET`. 288 | > If the a cleanup configuration in `DB_BACKUP_CLEANUP_TIME` is defined, the remote directory on Azure storage will also be cleaned automatically. 289 | 290 | 291 | ### Networking 292 | 293 | The following ports are exposed. 294 | 295 | | Port | Description | 296 | | ------ | -------------- | 297 | | `3306` | MariaDB Server | 298 | 299 | ## Maintenance 300 | Inside the image are tools to perform modification on how the image runs. 301 | 302 | ### Shell Access 303 | For debugging and maintenance purposes you may want access the containers shell. 304 | 305 | ```bash 306 | docker exec -it (whatever your container name is) bash 307 | ``` 308 | 309 | ### Mysql Tuner 310 | 311 | This image comes with [Mysql Tuner](https://github.com/major/MySQLTuner-perl). Simply enter inside the container and execute `mysql-tuner` along with your arguments. 312 | 313 | ### Manual Backups 314 | 315 | Manual Backups can be perforemd by entering the container and typing `backup-now` 316 | 317 | 318 | ## Contributions 319 | Welcomed. Please fork the repository and submit a [pull request](../../pulls) for any bug fixes, features or additions you propose to be included in the image. If it does not impact my intended usage case, it will be merged into the tree, tagged as a release and credit to the contributor in the [CHANGELOG](CHANGELOG). 320 | 321 | ## Support 322 | 323 | These images were built to serve a specific need in a production environment and gradually have had more functionality added based on requests from the community. 324 | ### Usage 325 | - The [Discussions board](../../discussions) is a great place for working with the community on tips and tricks of using this image. 326 | - [Sponsor me](https://tiredofit.ca/sponsor) for personalized support 327 | ### Bugfixes 328 | - Please, submit a [Bug Report](issues/new) if something isn't working as expected. I'll do my best to issue a fix in short order. 329 | 330 | ### Feature Requests 331 | - Feel free to submit a feature request, however there is no guarantee that it will be added, or at what timeline. 332 | - [Sponsor me](https://tiredofit.ca/sponsor) regarding development of features. 333 | 334 | ### Updates 335 | - Best effort to track upstream changes, More priority if I am actively using the image in a production environment. 336 | - [Sponsor me](https://tiredofit.ca/sponsor) for up to date releases. 337 | 338 | ## License 339 | MIT. See [LICENSE](LICENSE) for more details. 340 | 341 | 342 | ## References 343 | 344 | * https://mariadb.org 345 | -------------------------------------------------------------------------------- /examples/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | example-db: 3 | image: tiredofit/mariadb:10.11 4 | stop_grace_period: 3m 5 | container_name: example-db 6 | volumes: 7 | #- ./dbbackup:/bacup 8 | - ./db:/var/lib/mysql 9 | - ./logs:/logs 10 | environment: 11 | - TIMEZONE=America/Vancouver 12 | - CONTAINER_NAME=example-db 13 | 14 | - ROOT_PASS=rootpassword 15 | 16 | - DB_NAME=database 17 | - DB_USER=user 18 | - DB_PASS=password 19 | ### OR 20 | - DB01_NAME=database_one 21 | - DB01_USER=database_userone 22 | - DB01_PASS=password 23 | - DB02_NAME=database_two 24 | - DB02_USER=database_usertwo 25 | - DB02_PASS=password 26 | - DB03_NAME=database_three 27 | - DB03_USER=database_userone 28 | - DB03_PASS=password 29 | 30 | - DB_BACKUP=TRUE 31 | - DB_BACKUP_NAME=database_one 32 | - DB_BACKUP_USER=databae_userone 33 | - DB_BACKUP_PASS=password 34 | ### OR 35 | - DB_BACKUP_NAME=ALL 36 | - DB_BACKUP_USER=root 37 | - DB_BACKUP_PASS=rootpassword 38 | 39 | - DB_BACKUP_DUMP_FREQ=1440 40 | - DB_BACKUP_DUMP_BEGIN=2235 41 | 42 | - DB_BACKUP_COMPRESSION=ZSTD 43 | - DB_BACKUP_COMPRESSION_LEVEL=6 44 | networks: 45 | - services 46 | restart: always 47 | 48 | networks: 49 | services: 50 | external: true 51 | 52 | -------------------------------------------------------------------------------- /install/assets/defaults/10-mariadb: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | 3 | CONFIG_FILE=${CONFIG_FILE:-"my.cnf"} 4 | CONFIG_PATH=${CONFIG_PATH:-"/etc/mysql/"} 5 | CONFIG_CUSTOM_PATH=${CONFIG_CUSTOM_PATH:-"${CONFIG_PATH}/conf.d/"} 6 | LISTEN_PORT=${LISTEN_PORT:-"3306"} 7 | ## 8 | CREATE_DB=${CREATE_DB:-"TRUE"} 9 | DATA_PATH=${DATA_PATH:-"/var/lib/mysql/"} 10 | DB_AUTO_UPGRADE=${DB_AUTO_UPGRADE:-"TRUE"} 11 | DB_CHARACTER_SET=${DB_CHARACTER_SET:-"utf8mb4"} 12 | DB_COLLATION=${DB_COLLATION:-"utf8mb4_general_ci"} 13 | DB_CONFIGURATION=${DB_CONFIGURATION:-"standard"} 14 | DB_HOST=${DB_HOST:-"127.0.0.1"} 15 | ENABLE_LOG_ERROR=${ENABLE_LOG_ERROR:-"TRUE"} 16 | ENABLE_LOG_GENERAL_QUERY=${ENABLE_LOG_GENERAL_QUERY:-"FALSE"} 17 | ENABLE_LOG_SLOW_QUERY=${ENABLE_LOG_SLOW_QUERY:-"FALSE"} 18 | DB_PORT=${LISTEN_PORT:-"${LISTEN_PORT}"} 19 | LOG_FILE_ERROR=${LOG_FILE_ERROR:-"error.log"} 20 | LOG_LEVEL=${LOG_LEVEL:-"3"} 21 | LOG_FILE_SLOW_QUERY=${LOG_FILE_SLOW_QUERY:-"slowqueries.log"} 22 | LOG_FILE_GENERAL_QUERY=${LOG_FILE_GENERAL_QUERY:-"general.log"} 23 | LOG_PATH=${LOG_PATH:-"/logs/"} 24 | SOCKET_FILE=${SOCKET_FILE:-"mysqld.sock"} 25 | SOCKET_PATH=${SOCKET_PATH:-"/run/mysqld/"} 26 | -------------------------------------------------------------------------------- /install/assets/defaults/20-mariadb-backup: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | 3 | DB_BACKUP=${DB_BACKUP:-"FALSE"} 4 | DB_BACKUP_LOCATION=${DB_BACKUP_LOCATION:-"FILESYSTEM"} 5 | DB_BACKUP_BLOBXFER_REMOTE_PATH=${DB_BACKUP_BLOBXFER_REMOTE_PATH:-"/docker-db-backup"} 6 | DB_BACKUP_CHECKSUM=${DB_BACKUP_CHECKSUM:-"MD5"} 7 | DB_BACKUP_COMPRESSION=${DB_BACKUP_COMPRESSION:-"ZSTD"} 8 | DB_BACKUP_COMPRESSION_LEVEL=${DB_BACKUP_COMPRESSION_LEVEL:-"3"} 9 | DB_BACKUP_CREATE_LATEST_SYMLINK=${DB_BACKUP_CREATE_LATEST_SYMLINK:-"TRUE"} 10 | DB_BACKUP_DUMP_BEGIN=${DB_BACKUP_DUMP_BEGIN:-+0} 11 | DB_BACKUP_DUMP_FREQ=${DB_BACKUP_DUMP_FREQ:-1440} 12 | DB_BACKUP_DUMP_TARGET=${DB_BACKUP_DUMP_TARGET:-"/backup/"} 13 | DB_BACKUP_DUMP_TARGET_ARCHIVE=${DB_BACKUP_DUMP_TARGET_ARCHIVE:-"${DB_BACKUP_DUMP_TARGET}/archive/"} 14 | DB_BACKUP_ENABLE_CHECKSUM=${DB_BACKUP_ENABLE_CHECKSUM:-"TRUE"} 15 | DB_BACKUP_ENABLE_PARALLEL_COMPRESSION=${DB_BACKUP_ENABLE_PARALLEL_COMPRESSION:-"TRUE"} 16 | DB_BACKUP_MANUAL_RUN_FOREVER=${DB_BACKUP_MANUAL_RUN_FOREVER:-"TRUE"} 17 | DB_BACKUP_MODE=${DB_BACKUP_MODE:-"AUTO"} 18 | DB_BACKUP_MYSQL_ENABLE_TLS=${DB_BACKUP_MYSQL_ENABLE_TLS:-"FALSE"} 19 | DB_BACKUP_MYSQL_MAX_ALLOWED_PACKET=${DB_BACKUP_MYSQL_MAX_ALLOWED_PACKET:-"512M"} 20 | DB_BACKUP_MYSQL_SINGLE_TRANSACTION=${DB_BACKUP_MYSQL_SINGLE_TRANSACTION:-"TRUE"} 21 | DB_BACKUP_MYSQL_STORED_PROCEDURES=${DB_BACKUP_MYSQL_STORED_PROCEDURES:-"TRUE"} 22 | DB_BACKUP_MYSQL_TLS_CA_FILE=${DB_BACKUP_MYSQL_TLS_CA_FILE:-"/etc/ssl/cert.pem"} 23 | DB_BACKUP_MYSQL_TLS_VERIFY=${DB_BACKUP_MYSQL_TLS_VERIFY:-"FALSE"} 24 | DB_BACKUP_MYSQL_TLS_VERSION=${DB_BACKUP_MYSQL_TLS_VERSION:-"TLSv1.1,TLSv1.2,TLSv1.3"} 25 | DB_BACKUP_PARALLEL_COMPRESSION_THREADS=${DB_BACKUP_PARALLEL_COMPRESSION_THREADS:-"$(nproc)"} 26 | DB_BACKUP_S3_CERT_SKIP_VERIFY=${DB_BACKUP_S3_CERT_SKIP_VERIFY:-"TRUE"} 27 | DB_BACKUP_S3_PROTOCOL=${DB_BACKUP_S3_PROTOCOL:-"https"} 28 | DB_BACKUP_SCRIPT_LOCATION_PRE=${DB_BACKUP_SCRIPT_LOCATION_PRE:-"/assets/scripts/pre/"} 29 | DB_BACKUP_SCRIPT_LOCATION_POST=${DB_BACKUP_SCRIPT_LOCATION_POST:-"/assets/scripts/post/"} 30 | DB_BACKUP_SIZE_VALUE=${DB_BACKUP_SIZE_VALUE:-"bytes"} 31 | DB_BACKUP_SKIP_AVAILABILITY_CHECK=${DB_BACKUP_SKIP_AVAILABILITY_CHECK:-"FALSE"} 32 | DB_BACKUP_SPLIT_DB=${DB_BACKUP_SPLIT_DB:-"TRUE"} 33 | DB_BACKUP_TEMP_LOCATION=${DB_BACKUP_TEMP_LOCATION:-"/tmp/backups"} 34 | DB_BACKUP_TYPE=MARIADB 35 | 36 | -------------------------------------------------------------------------------- /install/assets/functions/10-mariadb: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | 3 | bootstrap_filesystem() { 4 | if [ -n "${CERT_PATH}" ] ; then 5 | if [ ! -d "${CERT_PATH}" ] ; then 6 | mkdir -p "${CERT_PATH}" 7 | fi 8 | if [ "$(stat -c %U "${CERT_PATH}")" != "mariadb" ] ; then silent chown -R mariadb:mariadb "${CERT_PATH}" ; fi 9 | fi 10 | 11 | if [ ! -d "${CONFIG_PATH}" ] ; then 12 | mkdir -p "${CONFIG_PATH}" 13 | fi 14 | if [ "$(stat -c %U "${CONFIG_PATH}")" != "mariadb" ] ; then silent chown -R mariadb:mariadb "${CONFIG_PATH}" ; fi 15 | if [ "$(stat -c %a "${CONFIG_PATH}")" != "755" ] ; then chmod -R 755 "${CONFIG_PATH}" ; fi 16 | 17 | if [ ! -d "${CONFIG_CUSTOM_PATH}" ] ; then 18 | mkdir -p "${CONFIG_CUSTOM_PATH}" 19 | fi 20 | if [ "$(stat -c %U "${CONFIG_CUSTOM_PATH}")" != "mariadb" ] ; then silent chown -R mariadb:mariadb "${CONFIG_CUSTOM_PATH}" ; fi 21 | if [ "$(stat -c %a "${CONFIG_CUSTOM_PATH}")" != "755" ] ; then chmod -R 755 "${CONFIG_CUSTOM_PATH}" ; fi 22 | 23 | if [ ! -d "${DATA_PATH}" ] ; then 24 | mkdir -p "${DATA_PATH}" 25 | fi 26 | if [ "$(stat -c %U "${DATA_PATH}")" != "mariadb" ] ; then chown -R mariadb:mariadb "${DATA_PATH}" ; fi 27 | if [ "$(stat -c %a "${DATA_PATH}")" != "700" ] ; then chmod -R 700 "${DATA_PATH}" ; fi 28 | 29 | if [ ! -d "${SOCKET_PATH}" ] ; then 30 | mkdir -p "${SOCKET_PATH}" 31 | fi 32 | if [ "$(stat -c %U "${SOCKET_PATH}")" != "mariadb" ] ; then chown -R mariadb:mariadb "${SOCKET_PATH}" ; fi 33 | if [ "$(stat -c %a "${SOCKET_PATH}")" != "755" ] ; then chmod -R 755 "${SOCKET_PATH}" ; fi 34 | 35 | if [ ! -d "${LOG_PATH}" ] ; then 36 | mkdir -p "${LOG_PATH}" 37 | fi 38 | if [ "$(stat -c %U "${LOG_PATH}")" != "mariadb" ] ; then chown mariadb:mariadb "${LOG_PATH}" ; fi 39 | } 40 | 41 | bootstrap_variables() { 42 | transform_file_var \ 43 | MYSQL_DATABASE \ 44 | MYSQL_PASSWORD \ 45 | MYSQL_ROOT_PASSWORD \ 46 | MYSQL_USER 47 | 48 | if [ -n "$MYSQL_ROOT_PASSWORD" ]; then 49 | ROOT_PASS=${MYSQL_ROOT_PASSWORD} 50 | fi 51 | 52 | if [ -n "$MYSQL_DATABASE" ]; then 53 | DB_NAME=${MYSQL_DATABASE} 54 | fi 55 | 56 | if [ -n "$MYSQL_USER" ]; then 57 | DB_USER=${MYSQL_USER} 58 | fi 59 | 60 | if [ -n "$MYSQL_PASSWORD" ]; then 61 | DB_PASS=${MYSQL_PASSWORD} 62 | fi 63 | 64 | transform_file_var \ 65 | ROOT_PASS 66 | } 67 | 68 | configure_mariadb() { 69 | case "${DB_CONFIGURATION,,}" in 70 | standard ) 71 | mysql_conf=standard.cnf 72 | ;; 73 | default | *) 74 | mysql_conf=default.cnf 75 | ;; 76 | esac 77 | 78 | cp -R /assets/mariadb/"${mysql_conf}" "${CONFIG_PATH}"/"${CONFIG_FILE}" 79 | chown mariadb:mariadb "${CONFIG_PATH}"/"${CONFIG_FILE}" 80 | update_template "${CONFIG_PATH}"/"${CONFIG_FILE}" \ 81 | CONFIG_CUSTOM_PATH \ 82 | DB_CHARACTER_SET \ 83 | DB_COLLATION \ 84 | LISTEN_PORT \ 85 | LOG_FILE_ERROR \ 86 | LOG_FILE_GENERAL_QUERY \ 87 | LOG_FILE_SLOW_QUERY \ 88 | LOG_PATH \ 89 | SOCKET_FILE \ 90 | SOCKET_PATH 91 | 92 | sed -i -e "s|log_warnings = .*|log_warnings = ${LOG_LEVEL}|g" "${CONFIG_PATH}""${CONFIG_FILE}" 93 | 94 | if var_true "${ENABLE_LOG_ERROR}" ; then 95 | create_logrotate mariadb-error "${LOG_PATH}"/"${LOG_FILE_ERROR}" mariadb-error mariadb mariadb 96 | else 97 | sed -i "s|log_error = .*|log_error = /dev/null|g" "${CONFIG_PATH}""${CONFIG_FILE}" 98 | fi 99 | 100 | if var_true "${ENABLE_LOG_GENERAL_QUERY}" ; then 101 | sed -i "s|general_log =.*|general_log = 1|g" "${CONFIG_PATH}""${CONFIG_FILE}" 102 | create_logrotate mariadb-generalquery "${LOG_PATH}"/"${LOG_FILE_GENERAL_QUERY}" none mariadb mariadb 103 | fi 104 | 105 | if var_true "${ENABLE_LOG_SLOW_QUERY}" ; then 106 | sed -i "s|slow_query_log_log =.*|slow_query_log = 1|g" "${CONFIG_PATH}""${CONFIG_FILE}" 107 | create_logrotate mariadb-slowquery "${LOG_PATH}"/"${LOG_FILE_SLOW_QUERY}" none mariadb mariadb 108 | fi 109 | 110 | chmod -R 0755 "${CONFIG_PATH}" 111 | } 112 | 113 | configure_monitoring() { 114 | if var_true "${CONTAINER_ENABLE_MONITORING}" && [ "${CONTAINER_MONITORING_BACKEND,,}" = "zabbix" ]; then 115 | source /assets/defaults/03-monitoring 116 | monitoring_init_file=$(sudo -u mariadb mktemp) 117 | monitor_password=$(pwgen 32 1 -s -v) 118 | cat < "${ZABBIX_CONFIG_PATH}"/"${ZABBIX_CONFIG_FILE}.d"/tiredofit_mariadb.conf 145 | # Zabbix MariaDB Configuration - Automatically Generated 146 | # Find Companion Zabbix Server Templates at https://github.com/tiredofit/docker-mariadb 147 | # Autoregister=${mariadb_autoreg} 148 | 149 | ${mariadb_config} 150 | EOF 151 | 152 | chmod 700 "${ZABBIX_CONFIG_PATH}"/"${ZABBIX_CONFIG_FILE}.d"/tiredofit_mariadb.conf 153 | chown zabbix:root "${ZABBIX_CONFIG_PATH}"/"${ZABBIX_CONFIG_FILE}.d"/tiredofit_mariadb.conf 154 | fi 155 | } 156 | 157 | control_server() { 158 | case "${1}" in 159 | start ) 160 | if [ "${2}" != "--skip-grant-tables" ] ; then sanity_var "ROOT_PASS" "ROOT Password" ; fi 161 | TZ=${TIMEZONE} silent s6-setuidgid mariadb \ 162 | /usr/bin/mysqld \ 163 | --defaults-file="${CONFIG_PATH}"/"${CONFIG_FILE}" \ 164 | --skip-name-resolve \ 165 | --skip-networking=on \ 166 | --user=mariadb ${2} > /dev/null & 167 | 168 | wait_for_socket "${SOCKET_PATH}"/"${SOCKET_FILE}" 169 | ;; 170 | stop ) 171 | TZ=${TIMEZONE} silent s6-setuidgid mariadb \ 172 | mysqladmin \ 173 | --socket "${SOCKET_PATH}"/"${SOCKET_FILE}" \ 174 | -uroot \ 175 | -p"${ROOT_PASS}" \ 176 | shutdown 177 | ;; 178 | esac 179 | } 180 | 181 | initialize_mariadb() { 182 | init_file=$(sudo -u mariadb mktemp) 183 | if [ -d "${DATA_PATH}"/mysql ]; then 184 | print_debug "MariaDB directory already present, skipping database creation" 185 | touch "${DATA_PATH}"/.version 186 | mariadb_run_major=$(echo "${MARIADB_VERSION}" | cut -d . -f 1,2) 187 | mariadb_file_major="$(head -n 1 "${DATA_PATH}"/.version | awk '{print $1}' | cut -d . -f 1,2)" 188 | if [ "${mariadb_run_major}" != "${mariadb_file_major}" ] ; then 189 | print_warn "Data Files Major version: '${mariadb_file_major}', but image runtime major version: '${mariadb_run_major}'" 190 | if var_true "${DB_AUTO_UPGRADE}" ; then 191 | if [ -n "${ROOT_PASS}" ] ; then 192 | print_notice "Upgrading database files to '${MARIADB_VERSION}' version" 193 | control_server start "--skip-grant-tables" 194 | sanity_db 195 | silent sudo -u mariadb \ 196 | mysql_upgrade \ 197 | -uroot \ 198 | --silent 199 | exitcode_upgrade=$? 200 | control_server stop 201 | if [ "${exitcode_upgrade}" != "0" ] ; then 202 | print_error "MariaDB Upgrade failed with exit code '${exitcode_upgrade}'. Halting initialization. Leaving MariaDB background process running.." 203 | exit 1 204 | fi 205 | echo "${MARIADB_VERSION} upgraded on $(TZ=${TIMEZONE} date +'%Y-%m-%d %H:%M:%S %Z')" | cat - "${DATA_PATH}"/.version > /tmp/.version && mv /tmp/.version "${DATA_PATH}"/.version 206 | chown -R root:root "${DATA_PATH}"/.version 207 | else 208 | print_warn "Can't upgrade to '${MARIADB_VERSION}' as I don't know the ROOT PASS" 209 | fi 210 | else 211 | print_warn "Skipping upgrading databases to ${MARIADB_VERSION} version" 212 | fi 213 | fi 214 | 215 | if [ "${MARIADB_VERSION}" != "$(head -n 1 "${DATA_PATH}"/.version | awk '{print $1}')" ]; then 216 | print_warn "Installed version: '$(head -n 1 "${DATA_PATH}"/.version | awk '{print $1}')', but image version: '${MARIADB_VERSION}'" 217 | print_warn "Consider running mysql_upgrade" 218 | #echo "${MARIADB_VERSION} started being used without executing 'mysql_upgrade' on $(TZ=${TIMEZONE} date +'%Y-%m-%d %H:%M:%S %Z')" | cat - "${DATA_PATH}".version > /tmp/.version && mv /tmp/.version "${DATA_PATH}".version 219 | fi 220 | 221 | chown -R mariadb:mariadb "${DATA_PATH}" 222 | else 223 | print_warn "MariaDB data directory is not found, creating initial DB(s)" 224 | sanity_var ROOT_PASS "Root Password" 225 | 226 | silent s6-setuidgid mariadb mysql_install_db \ 227 | --user=mariadb \ 228 | --basedir=/usr \ 229 | --datadir="${DATA_PATH}" \ 230 | --defaults-file="${CONFIG_PATH}"/"${CONFIG_FILE}" \ 231 | --auth-root-authentication-method=normal 232 | 233 | cat < "${DATA_PATH}".version 263 | fi 264 | 265 | rm -rf "${init_file}" 266 | } 267 | 268 | create_databases() { 269 | if var_true "${CREATE_DB}" ; then 270 | control_server start "--skip-grant-tables" 271 | transform_file_var \ 272 | DB_NAME \ 273 | DB_USER \ 274 | DB_PASS 275 | if [ -n "${DB_NAME}" ] && [ -z "${DB01_NAME}" ] ; then export DB01_NAME="${DB_NAME}" ; unset DB_NAME ; fi 276 | if [ -n "${DB_USER}" ] && [ -z "${DB01_USER}" ] ; then export DB01_USER="${DB_USER}" ; unset DB_USER ; fi 277 | if [ -n "${DB_PASS}" ] && [ -z "${DB01_PASS}" ] ; then export DB01_PASS="${DB_PASS}" ; unset DB_PASS ; fi 278 | database_init_file=$(sudo -u mariadb mktemp) 279 | dbnum=$(printenv | sort | grep -cE '^DB([0-9].)_NAME') 280 | for (( i = 01; i <= dbnum; i++ )) ; do 281 | i=$(printf "%02d" $i) 282 | transform_file_var \ 283 | DB${i}_NAME \ 284 | DB${i}_USER \ 285 | DB${i}_PASS 286 | DB_NAME=DB${i}_NAME 287 | DB_USER=DB${i}_USER 288 | DB_PASS=DB${i}_PASS 289 | 290 | if [ -n "${!DB_NAME}" ] ; then 291 | if ! silent mysql -uroot --skip-column-names -e "use ${!DB_NAME};" ; then 292 | print_notice "[create_databases] Creating Database: '${!DB_NAME}'" 293 | cat < "${DB_BACKUP_TEMP_LOCATION}"/"${target}" 87 | exit_code=$? 88 | backup_check_exit_code $target 89 | backup_generate_checksum 90 | backup_move_dbbackup 91 | backup_post_dbbackup $db 92 | done 93 | else 94 | print_debug "Not splitting database dumps into their own files" 95 | backup_prepare_dbbackup 96 | target=mysql_all_${CONTAINER_NAME,,}_${now}.sql 97 | backup_compression 98 | backup_pre_dbbackup all 99 | print_notice "Dumping all MySQL / MariaDB databases: '$(echo ${db_names} | xargs | tr ' ' ',')' ${compression_string}" 100 | mysqldump --socket=/var/run/mysqld/mysqld.sock --max-allowed-packet=${DB_BACKUP_MYSQL_MAX_ALLOWED_PACKET} -u${DB_BACKUP_USER} ${single_transaction} ${stored_procedures} ${mysql_tls_args} ${DB_BACKUP_EXTRA_OPTS} --databases $(echo ${db_names} | xargs) | $compress_cmd > "${DB_BACKUP_TEMP_LOCATION}"/"${target}" 101 | exit_code=$? 102 | backup_check_exit_code $target 103 | backup_generate_checksum 104 | backup_move_dbbackup 105 | backup_post_dbbackup all 106 | fi 107 | } 108 | 109 | backup_check_availability() { 110 | ### Set the Database Type 111 | if var_false "${DB_BACKUP_SKIP_AVAILABILITY_CHECK}" ; then 112 | case "$dbtype" in 113 | "mysql" ) 114 | counter=0 115 | export MYSQL_PWD=${DB_BACKUP_PASS} 116 | while ! (mysqladmin --socket=/var/run/mysqld/mysqld.sock -u"${DB_BACKUP_USER}" ${mysql_tls_args} ${DB_BACKUP_EXTRA_OPTS} status > /dev/null 2>&1) ; do 117 | sleep 5 118 | (( counter+=5 )) 119 | print_warn "MySQL/MariaDB Server is not accessible, retrying.. (${counter} seconds so far)" 120 | done 121 | ;; 122 | esac 123 | fi 124 | } 125 | 126 | backup_check_exit_code() { 127 | print_debug "DB Backup Exit Code is ${exit_code}" 128 | case "${exit_code}" in 129 | 0 ) 130 | print_info "DB Backup of '${1}' completed successfully" 131 | ;; 132 | * ) 133 | print_error "DB Backup of '${1}' reported errors" 134 | master_exit_code=1 135 | ;; 136 | esac 137 | } 138 | 139 | backup_cleanup_old_data() { 140 | if [ -n "${DB_BACKUP_CLEANUP_TIME}" ]; then 141 | if [ "${master_exit_code}" != 1 ]; then 142 | case "${DB_BACKUP_BACKUP_LOCATION,,}" in 143 | "blobxfer" ) 144 | print_info "Cleaning up old backups on filesystem" 145 | mkdir -p "${DB_BACKUP_DUMP_TARGET}" 146 | find "${DB_BACKUP_DUMP_TARGET}"/ -mmin +"${DB_CLEANUP_TIME}" -iname "*" -exec rm {} \; 147 | print_info "Syncing changes via blobxfer" 148 | silent blobxfer upload --mode file --remote-path ${DB_BACKUP_BLOBXFER_REMOTE_PATH} --local-path ${DB_BACKUP_DUMP_TARGET} --delete --delete-only 149 | ;; 150 | "file" | "filesystem" ) 151 | print_info "Cleaning up old backups on filesystem" 152 | mkdir -p "${DB_BACKUP_DUMP_TARGET}" 153 | find "${DB_BACKUP_DUMP_TARGET}"/ -mmin +"${DB_BACKUP_CLEANUP_TIME}" -iname "*" -exec rm {} \; 154 | ;; 155 | "s3" | "minio" ) 156 | print_info "Cleaning up old backups on S3 storage" 157 | aws ${DB_BACKUP_PARAM_AWS_ENDPOINT_URL} s3 ls s3://${DB_BACKUP_S3_BUCKET}/${DB_BACKUP_S3_PATH}/ ${s3_ssl} ${s3_ca_cert} ${DB_BACKUP_S3_EXTRA_OPTS} | grep " DIR " -v | grep " PRE " -v | while read -r s3_file; do 158 | s3_createdate=$(echo $s3_file | awk {'print $1" "$2'}) 159 | s3_createdate=$(date -d "$s3_createdate" "+%s") 160 | s3_olderthan=$(echo $(( $(date +%s)-${DB_BACKUP_CLEANUP_TIME}*60 ))) 161 | if [[ $s3_createdate -le $s3_olderthan ]] ; then 162 | s3_filename=$(echo $s3_file | awk {'print $4'}) 163 | if [ "$s3_filename" != "" ] ; then 164 | print_debug "Deleting $s3_filename" 165 | aws ${DB_BACKUP_PARAM_AWS_ENDPOINT_URL} s3 rm s3://${DB_BACKUP_S3_BUCKET}/${DB_BACKUP_S3_PATH}/${s3_filename} ${s3_ssl} ${s3_ca_cert} ${DB_BACKUP_S3_EXTRA_OPTS} 166 | fi 167 | fi 168 | 169 | done 170 | ;; 171 | esac 172 | else 173 | print_error "Skipping Cleaning up old backups because there were errors in backing up" 174 | fi 175 | fi 176 | } 177 | 178 | backup_compression() { 179 | if var_false "${DB_BACKUP_ENABLE_PARALLEL_COMPRESSION}" ; then 180 | DB_BACKUP_PARALLEL_COMPRESSION_THREADS=1 181 | fi 182 | 183 | case "${DB_BACKUP_COMPRESSION,,}" in 184 | gz* ) 185 | if var_true "${DB_BACKUP_GZ_RSYNCABLE}" ; then 186 | gz_rsyncable=--rsyncable 187 | fi 188 | compress_cmd="pigz -q -${DB_BACKUP_COMPRESSION_LEVEL} -p ${DB_BACKUP_PARALLEL_COMPRESSION_THREADS} ${gz_rsyncable}" 189 | compression_type="gzip" 190 | extension=".gz" 191 | dir_compress_cmd=${compress_cmd} 192 | target_dir=${target} 193 | target=${target}.gz 194 | ;; 195 | bz* ) 196 | compress_cmd="pbzip2 -q -${DB_BACKUP_COMPRESSION_LEVEL} -p${DB_BACKUP_PARALLEL_COMPRESSION_THREADS} " 197 | compression_type="bzip2" 198 | dir_compress_cmd=${compress_cmd} 199 | extension=".bz2" 200 | target_dir=${target} 201 | target=${target}.bz2 202 | ;; 203 | xz* ) 204 | compress_cmd="pixz -${DB_BACKUP_COMPRESSION_LEVEL} -p ${DB_BACKUP_PARALLEL_COMPRESSION_THREADS} " 205 | compression_type="xzip" 206 | dir_compress_cmd=${compress_cmd} 207 | extension=".xz" 208 | target_dir=${target} 209 | target=${target}.xz 210 | ;; 211 | zst* ) 212 | compress_cmd="zstd -q -q --rm -${DB_BACKUP_COMPRESSION_LEVEL} -T${DB_BACKUP_PARALLEL_COMPRESSION_THREADS} " 213 | compression_type="zstd" 214 | dir_compress_cmd=${compress_cmd} 215 | extension=".zst" 216 | target_dir=${target} 217 | target=${target}.zst 218 | ;; 219 | "none" | "false") 220 | compress_cmd="cat " 221 | compression_type="none" 222 | dir_compress_cmd="cat " 223 | target_dir=${target} 224 | ;; 225 | esac 226 | 227 | case "${CONTAINER_LOG_LEVEL,,}" in 228 | "debug" ) 229 | if [ "${compression_type}" = "none" ] ; then 230 | compression_string="with '${DB_BACKUP_PARALLEL_COMPRESSION_THREADS}' threads" 231 | else 232 | compression_string="and compressing with '${compression_type}:${DB_BACKUP_COMPRESSION_LEVEL}' with '${DB_BACKUP_PARALLEL_COMPRESSION_THREADS}' threads" 233 | fi 234 | ;; 235 | * ) 236 | if [ "${compression_type}" != "none" ] ; then 237 | compression_string="and compressing with '${compression_type}'" 238 | fi 239 | ;; 240 | esac 241 | } 242 | 243 | backup_create_archive() { 244 | if [ "${exit_code}" = "0" ] ; then 245 | print_notice "Creating archive file of '${target_dir}' with tar ${compression_string}" 246 | tar cf - "${DB_BACKUP_TEMP_LOCATION}"/"${target_dir}" | $dir_compress_cmd > "${DB_BACKUP_TEMP_LOCATION}"/"${target_dir}".tar"${extension}" 247 | else 248 | print_error "Skipping creating archive file because backup did not complete successfully" 249 | fi 250 | } 251 | 252 | backup_generate_checksum() { 253 | if var_true "${DB_BACKUP_ENABLE_CHECKSUM}" ; then 254 | if [ "${exit_code}" = "0" ] ; then 255 | case "${DB_BACKUP_CHECKSUM,,}" in 256 | "md5" ) 257 | checksum_command="md5sum" 258 | checksum_extension="md5" 259 | ;; 260 | "sha1" ) 261 | checksum_command="sha1sum" 262 | checksum_extension="sha1" 263 | ;; 264 | esac 265 | 266 | print_notice "Generating ${checksum_extension^^} for '${target}'" 267 | cd "${DB_BACKUP_TEMP_LOCATION}" 268 | ${checksum_command} "${target}" > "${target}"."${checksum_extension}" 269 | checksum_value=$(${checksum_command} "${target}" | awk ' { print $1}') 270 | print_debug "${checksum_extension^^}: ${checksum_value} - ${target}" 271 | else 272 | print_error "Skipping Checksum creation because backup did not complete successfully" 273 | fi 274 | fi 275 | } 276 | 277 | backup_move_dbbackup() { 278 | if [ "${exit_code}" = "0" ] ; then 279 | dbbackup_size="$(stat -c%s "${DB_BACKUP_TEMP_LOCATION}"/"${target}")" 280 | dbbackup_date="$(date -r "${DB_BACKUP_TEMP_LOCATION}"/"${target}" +'%s')" 281 | 282 | case "${DB_BACKUP_SIZE_VALUE,,}" in 283 | "b" | "bytes" ) 284 | DB_BACKUP_SIZE_VALUE=1 285 | ;; 286 | "[kK]" | "[kK][bB]" | "kilobytes" | "[mM]" | "[mM][bB]" | "megabytes" ) 287 | DB_BACKUP_SIZE_VALUE="-h" 288 | ;; 289 | *) 290 | DB_BACKUP_SIZE_VALUE=1 291 | ;; 292 | esac 293 | if [ "${DB_BACKUP_SIZE_VALUE}" = "1" ] ; then 294 | filesize=$(stat -c%s "${DB_BACKUP_TEMP_LOCATION}"/"${target}") 295 | print_notice "Backup of ${target} created with the size of ${filesize} bytes" 296 | else 297 | filesize=$(du -h "${DB_BACKUP_TEMP_LOCATION}"/"${target}" | awk '{ print $1}') 298 | print_notice "Backup of ${target} created with the size of ${filesize}" 299 | fi 300 | 301 | case "${DB_BACKUP_LOCATION,,}" in 302 | "file" | "filesystem" ) 303 | print_debug "Moving backup to filesystem" 304 | mkdir -p "${DB_BACKUP_DUMP_TARGET}" 305 | mv "${DB_BACKUP_TEMP_LOCATION}"/*."${checksum_extension}" "${DB_BACKUP_DUMP_TARGET}"/ 306 | mv "${DB_BACKUP_TEMP_LOCATION}"/"${target}" "${DB_BACKUP_DUMP_TARGET}"/"${target}" 307 | if var_true "${DB_BACKUP_CREATE_LATEST_SYMLINK}" ; then 308 | ln -sf "${DB_BACKUP_DUMP_TARGET}"/"${target}" "${DB_BACKUP_DUMP_TARGET}"/latest-"${ltarget}" 309 | fi 310 | if [ -n "${DB_BACKUP_ARCHIVE_TIME}" ] ; then 311 | mkdir -p "${DB_BACKUP_DUMP_TARGET_ARCHIVE}" 312 | find "${DB_BACKUP_DUMP_TARGET}"/ -maxdepth 1 -mmin +"${DB_BACKUP_ARCHIVE_TIME}" -iname "*" -exec mv {} "${DB_BACKUP_DUMP_TARGET_ARCHIVE}" \; 313 | fi 314 | ;; 315 | "s3" | "minio" ) 316 | print_debug "Moving backup to S3 Bucket" 317 | if [ -n "${DB_BACKUP_S3_KEY_ID}" ] && [ -n "${DB_BACKUP_S3_KEY_SECRET}" ]; then 318 | export AWS_ACCESS_KEY_ID=${DB_BACKUP_S3_KEY_ID} 319 | export AWS_SECRET_ACCESS_KEY=${DB_BACKUP_S3_KEY_SECRET} 320 | else 321 | print_debug "Variable DB_BACKUP_S3_KEY_ID or DB_BACKUP_S3_KEY_SECRET is not set. Please ensure sufficiant IAM role is assigned." 322 | fi 323 | export AWS_DEFAULT_REGION=${DB_BACKUP_S3_REGION} 324 | if [ -f "${DB_BACKUP_S3_CERT_CA_FILE}" ] ; then 325 | print_debug "Using Custom CA for S3 Backups" 326 | s3_ca_cert="--ca-bundle ${DB_BACKUP_S3_CERT_CA_FILE}" 327 | fi 328 | if var_true "${DB_BACKUP_S3_CERT_SKIP_VERIFY}" ; then 329 | print_debug "Skipping SSL verification for HTTPS S3 Hosts" 330 | s3_ssl="--no-verify-ssl" 331 | fi 332 | 333 | [[ ( -n "${DB_BACKUP_S3_HOST}" ) ]] && DB_BACKUP_PARAM_AWS_ENDPOINT_URL=" --endpoint-url ${DB_BACKUP_S3_PROTOCOL}://${DB_BACKUP_S3_HOST}" 334 | 335 | silent aws ${DB_BACKUP_PARAM_AWS_ENDPOINT_URL} s3 cp ${DB_BACKUP_TEMP_LOCATION}/${target} s3://${DB_BACKUP_S3_BUCKET}/${DB_BACKUP_S3_PATH}/${target} ${s3_ssl} ${s3_ca_cert} ${DB_BACKUP_S3_EXTRA_OPTS} 336 | if var_true "${DB_BACKUP_ENABLE_CHECKSUM}" ; then 337 | silent aws ${DB_BACKUP_PARAM_AWS_ENDPOINT_URL} s3 cp ${DB_BACKUP_TEMP_LOCATION}/*.${checksum_extension} s3://${DB_BACKUP_S3_BUCKET}/${DB_BACKUP_S3_PATH}/ ${s3_ssl} ${s3_ca_cert} ${DB_BACKUP_S3_EXTRA_OPTS} 338 | fi 339 | 340 | rm -rf "${DB_BACKUP_TEMP_LOCATION}"/*."${checksum_extension}" 341 | rm -rf "${DB_BACKUP_TEMP_LOCATION}"/"${target}" 342 | ;; 343 | "blobxfer" ) 344 | print_info "Moving backup to S3 Bucket with blobxfer" 345 | 346 | mkdir -p "${DB_BACKUP_DUMP_TARGET}" 347 | mv "${DB_BACKUP_TEMP_LOCATION}"/*."${checksum_extension}" "${DB_BACKUP_DUMP_TARGET}"/ 348 | mv "${DB_BACKUP_TEMP_LOCATION}"/"${target}" "${DB_BACKUP_DUMP_TARGET}"/"${target}" 349 | 350 | silent blobxfer upload --mode file --remote-path ${DB_BACKUP_BLOBXFER_REMOTE_PATH} --local-path ${DB_BACKUP_DUMP_TARGET} 351 | 352 | rm -rf "${DB_BACKUP_TEMP_LOCATION}"/*."${checksum_extension}" 353 | rm -rf "${DB_BACKUP_TEMP_LOCATION}"/"${target}" 354 | ;; 355 | esac 356 | else 357 | print_error "Skipping moving DB Backup to final location because backup did not complete successfully" 358 | fi 359 | 360 | rm -rf "${DB_BACKUP_TEMP_LOCATION}"/* 361 | } 362 | 363 | backup_prepare_dbbackup() { 364 | dbbackup_start_time=$(date +"%s") 365 | now=$(date +"%Y%m%d-%H%M%S") 366 | now_time=$(date +"%H:%M:%S") 367 | now_date=$(date +"%Y-%m-%d") 368 | ltarget=${dbtype}_${DB_BACKUP_NAME,,}_${CONTAINER_NAME,,} 369 | target=${dbtype}_${DB_BACKUP_NAME,,}_${CONTAINER_NAME,,}_${now}.sql 370 | } 371 | 372 | backup_pre_dbbackup() { 373 | ### Pre Script Support 374 | if [ -n "${DB_BACKUP_PRE_SCRIPT}" ] ; then 375 | if var_true "${DB_BACKUP_PRE_SCRIPT_SKIP_X_VERIFY}" ; then 376 | eval "${DB_BACKUP_PRE_SCRIPT}" "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${target}" 377 | else 378 | if [ -x "${DB_BACKUP_PRE_SCRIPT}" ] ; then 379 | print_notice "Found PRE_SCRIPT environment variable. Executing '${DB_BACKUP_PRE_SCRIPT}" 380 | eval "${DB_BACKUP_PRE_SCRIPT}" "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${target}" 381 | else 382 | print_error "Can't execute DB_BACKUP_PRE_SCRIPT environment variable '${DB_BACKUP_PRE_SCRIPT}' as its filesystem bit is not executible!" 383 | fi 384 | fi 385 | fi 386 | 387 | ### Pre Backup Custom Script Support 388 | if [ -d "/assets/custom-scripts/pre" ] && dir_notempty "/assets/custom-scripts/pre" ; then 389 | print_warning "Found Custom Post Scripts in /assets/custom-scripts/pre - Automatically moving them to '${DB_BACKUP_SCRIPT_LOCATION_PRE}'" 390 | mkdir -p "${DB_BACKUP_SCRIPT_LOCATION_PRE}" 391 | silent cp /assets/custom-scripts/pre/* "${DB_BACKUP_SCRIPT_LOCATION_PRE}" 392 | fi 393 | 394 | if [ -d "${DB_BACKUP_SCRIPT_LOCATION_PRE}" ] && dir_notempty "${DB_BACKUP_SCRIPT_LOCATION_PRE}" ; then 395 | for f in $(find ${DB_BACKUP_SCRIPT_LOCATION_PRE} -name \*.sh -type f); do 396 | if var_true "${DB_BACKUP_PRE_SCRIPT_SKIP_X_VERIFY}" ; then 397 | ${f} "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${target}" 398 | else 399 | if [ -x "${f}" ] ; then 400 | print_notice "Executing pre backup custom script : '${f}'" 401 | ## script DB_TYPE CONTAINER_NAME DB_NAME STARTEPOCH BACKUP_FILENAME 402 | ${f} "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${target}" 403 | else 404 | print_error "Can't run pre backup custom script: '${f}' as its filesystem bit is not executible!" 405 | fi 406 | fi 407 | done 408 | fi 409 | } 410 | 411 | backup_post_dbbackup() { 412 | dbbackup_finish_time=$(date +"%s") 413 | dbbackup_total_time=$(echo $((dbbackup_finish_time-dbbackup_start_time))) 414 | 415 | if var_true "${CONTAINER_ENABLE_MONITORING}" && [ "${CONTAINER_MONITORING_BACKEND,,}" = "zabbix" ]; then 416 | print_notice "Sending Backup Statistics to Zabbix" 417 | silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.size -o "${dbbackup_size}" 418 | silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.datetime -o "${dbbackup_date}" 419 | silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.status -o "${exit_code}" 420 | silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.backup_duration -o "$(echo $((dbbackup_finish_time-dbbackup_start_time)))" 421 | if [ "$?" != "0" ] ; then print_error "Error sending statistics, consider disabling with 'CONTAINER_ENABLE_MONITORING=FALSE'" ; fi 422 | fi 423 | 424 | ### Post Script Support 425 | if [ -n "${DB_BACKUP_POST_SCRIPT}" ] ; then 426 | if var_true "${DB_BACKUP_POST_SCRIPT_SKIP_X_VERIFY}" ; then 427 | eval "${DB_BACKUP_POST_SCRIPT}" "${exit_code}" "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${dbbackup_finish_time}" "${dbbackup_total_time}" "${target}" "${filesize}" "${checksum_value}" 428 | else 429 | if [ -x "${DB_BACKUP_POST_SCRIPT}" ] ; then 430 | print_notice "Found POST_SCRIPT environment variable. Executing '${DB_BACKUP_POST_SCRIPT}" 431 | eval "${DB_BACKUP_POST_SCRIPT}" "${exit_code}" "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${dbbackup_finish_time}" "${dbbackup_total_time}" "${target}" "${filesize}" "${checksum_value}" 432 | else 433 | print_error "Can't execute POST_SCRIPT environment variable '${DB_BACKUP_POST_SCRIPT}' as its filesystem bit is not executible!" 434 | fi 435 | fi 436 | fi 437 | 438 | ### Post Backup Custom Script Support 439 | if [ -d "/assets/custom-scripts/" ] && dir_notempty "/assets/custom-scripts" ; then 440 | print_warning "Found Custom Post Scripts in /assets/custom-scripts/ - Automatically moving them to '${DB_BACKUP_SCRIPT_LOCATION_POST}'" 441 | mkdir -p "${DB_BACKUP_SCRIPT_LOCATION_POST}" 442 | silent cp /assets/custom-scripts/* "${DB_BACKUP_SCRIPT_LOCATION_POST}" 443 | fi 444 | 445 | if [ -d "${DB_BACKUP_SCRIPT_LOCATION_POST}" ] && dir_notempty "${DB_BACKUP_SCRIPT_LOCATION_POST}" ; then 446 | for f in $(find ${DB_BACKUP_SCRIPT_LOCATION_POST} -name \*.sh -type f); do 447 | if var_true "${DB_BACKUP_POST_SCRIPT_SKIP_X_VERIFY}" ; then 448 | ${f} "${exit_code}" "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${dbbackup_finish_time}" "${dbbackup_total_time}" "${target}" "${filesize}" "${checksum_value}" 449 | else 450 | if [ -x "${f}" ] ; then 451 | print_notice "Executing post backup custom script : '${f}'" 452 | ## script EXIT_CODE DB_TYPE CONTAINER_NAME DB_NAME STARTEPOCH FINISHEPOCH DURATIONEPOCH BACKUP_FILENAME FILESIZE CHECKSUMVALUE 453 | ${f} "${exit_code}" "${dbtype}" "${CONTAINER_NAME}" "${1}" "${dbbackup_start_time}" "${dbbackup_finish_time}" "${dbbackup_total_time}" "${target}" "${filesize}" "${checksum_value}" 454 | else 455 | print_error "Can't run post backup custom script: '${f}' as its filesystem bit is not executible!" 456 | fi 457 | fi 458 | done 459 | fi 460 | 461 | print_notice "DB Backup for '${1}' time taken: $(echo ${dbbackup_total_time} | awk '{printf "Hours: %d Minutes: %02d Seconds: %02d", $1/3600, ($1/60)%60, $1%60}')" 462 | unset s3_ssl 463 | unset s3_ca_cert 464 | } 465 | 466 | backup_sanity_test() { 467 | sanity_var DB_BACKUP_TYPE "Database Type" 468 | 469 | case "${DB_BACKUP_TYPE,,}" in 470 | "mysql" | "mariadb" ) 471 | sanity_var DB_BACKUP_NAME "Database Name to backup. Multiple seperated by commas" 472 | ;; 473 | esac 474 | 475 | if [ "${DB_BACKUP_LOCATION,,}" = "s3" ] || [ "${DB_BACKUP_LOCATION,,}" = "minio" ] && [ -n "${DB_BACKUP_S3_KEY_ID}" ] && [ -n "${DB_BACKUP_S3_KEY_SECRET}" ]; then 476 | sanity_var DB_BACKUP_S3_BUCKET "S3 Bucket" 477 | sanity_var DB_BACKUP_S3_PATH "S3 Path" 478 | sanity_var DB_BACKUP_S3_REGION "S3 Region" 479 | file_env 'DB_BACKUP_S3_KEY_ID' 480 | file_env 'DB_BACKUP_S3_KEY_SECRET' 481 | fi 482 | } 483 | 484 | backup_setup_mode() { 485 | if [ "${DB_BACKUP_MODE,,}" = "auto" ] || [ ${DB_BACKUP_MODE,,} = "default" ] ; then 486 | print_debug "Running in Auto / Default Mode - Letting Image control scheduling" 487 | else 488 | print_info "Running in Manual mode - Execute 'backup_now' or '/etc/services.available/10-db-backup/run' to perform a manual backup" 489 | service_stop 10-db-backup 490 | if var_true "${DB_BACKUP_MANUAL_RUN_FOREVER}" ; then 491 | mkdir -p /etc/services.d/99-run_forever 492 | cat < /etc/services.d/99-run_forever/run 493 | 494 | #!/bin/bash 495 | while true 496 | do 497 | sleep 86400 498 | done 499 | EOF 500 | chmod +x /etc/services.d/99-run_forever/run 501 | else 502 | if var_true "${CONTAINER_ENABLE_SCHEDULING}" ; then 503 | print_error "Manual / Exit after execution mode doesn't work with 'CONTAINER_ENABLE_SCHEDULING=TRUE'" 504 | exit 1 505 | fi 506 | if var_true "${CONTAINER_ENABLE_MONITORING}" ; then 507 | print_error "Manual / Exit after execution mode doesn't work with 'CONTAINER_ENABLE_MONITORING=TRUE'" 508 | exit 1 509 | fi 510 | if var_true "${CONTAINER_ENABLE_LOGSHIPPING}" ; then 511 | print_error "Manual / Exit after execution mode doesn't work with 'CONTAINER_ENABLE_LOGSHIPPING=TRUE'" 512 | exit 1 513 | fi 514 | fi 515 | fi 516 | } 517 | -------------------------------------------------------------------------------- /install/assets/mariadb/default.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | port = 3306 3 | socket = {{SOCKET_PATH}}/{{SOCKET_FILE}} 4 | default-character-set = {{DB_CHARACTER_SET}} 5 | 6 | [mysqld_safe] 7 | socket = {{SOCKET_PATH}}/{{SOCKET_FILE}} 8 | nice = 0 9 | 10 | [mysqld] 11 | user = mariadb 12 | pid-file = /var/run/mysqld/mysqld.pid 13 | socket = {{SOCKET_PATH}}/{{SOCKET_FILE}} 14 | port = {{LISTEN_PORT}} 15 | basedir = /usr 16 | datadir = /var/lib/mysql 17 | tmpdir = /tmp 18 | lc_messages_dir = /usr/share/mysql 19 | lc_messages = en_US 20 | skip-external-locking 21 | 22 | max_connections = 100 23 | connect_timeout = 5 24 | wait_timeout = 600 25 | max_allowed_packet = 16M 26 | thread_cache_size = 128 27 | sort_buffer_size = 4M 28 | bulk_insert_buffer_size = 16M 29 | tmp_table_size = 32M 30 | max_heap_table_size = 32M 31 | 32 | character-set-server = {{DB_CHARACTER_SET}} 33 | collation-server = {{DB_COLLATION}} 34 | 35 | # 36 | # * MyISAM 37 | # 38 | # This replaces the startup script and checks MyISAM tables if needed 39 | # the first time they are touched. On error, make copy and try a repair. 40 | myisam_recover_options = BACKUP 41 | key_buffer_size = 128M 42 | #open-files-limit = 2000 43 | table_open_cache = 400 44 | myisam_sort_buffer_size = 512M 45 | concurrent_insert = 2 46 | read_buffer_size = 2M 47 | read_rnd_buffer_size = 1M 48 | 49 | # 50 | # * Query Cache Configuration 51 | # 52 | # Cache only tiny result sets, so we can fit more in the query cache. 53 | query_cache_limit = 128K 54 | query_cache_size = 64M 55 | # for more write intensive setups, set to DEMAND or OFF 56 | #query_cache_type = DEMAND 57 | # 58 | 59 | # * Logging and Replication 60 | # 61 | # Both location gets rotated by the cronjob. 62 | # Be aware that this log type is a performance killer. 63 | # As of 5.1 you can enable the log at runtime! 64 | #general_log_file = /var/log/mysql/mysql.log 65 | #general_log = 1 66 | # 67 | # Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf. 68 | # 69 | # we do want to know about network errors and such 70 | #log_warnings = 2 71 | # 72 | # Enable the slow query log to see queries with especially long duration 73 | #slow_query_log[={0|1}] 74 | 75 | long_query_time = 10 76 | #log_slow_rate_limit = 1000 77 | #log_slow_verbosity = query_plan 78 | 79 | #log-queries-not-using-indexes 80 | #log_slow_admin_statements 81 | # 82 | 83 | # The following can be used as easy to replay backup logs or for replication. 84 | # note: if you are setting up a replication slave, see README.Debian about 85 | # other settings you may need to change. 86 | #server-id = 1 87 | #report_host = master1 88 | #auto_increment_increment = 2 89 | #auto_increment_offset = 1 90 | #log_bin = /var/log/mysql/mariadb-bin 91 | #log_bin_index = /var/log/mysql/mariadb-bin.index 92 | # not fab for performance, but safer 93 | #sync_binlog = 1 94 | expire_logs_days = 10 95 | max_binlog_size = 100M 96 | # slaves 97 | #relay_log = /var/log/mysql/relay-bin 98 | #relay_log_index = /var/log/mysql/relay-bin.index 99 | #relay_log_info_file = /var/log/mysql/relay-bin.info 100 | #log_slave_updates 101 | #read_only 102 | # 103 | # If applications support it, this stricter sql_mode prevents some 104 | # mistakes like inserting invalid dates etc. 105 | #sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL 106 | 107 | # 108 | # * InnoDB 109 | # 110 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 111 | # Read the manual for more InnoDB related options. There are many! 112 | default_storage_engine = InnoDB 113 | # you can't just change log file size, requires special procedure 114 | #innodb_log_file_size = 50M 115 | innodb_buffer_pool_size = 256M 116 | innodb_log_buffer_size = 8M 117 | innodb_file_per_table = 1 118 | innodb_open_files = 400 119 | innodb_io_capacity = 400 120 | innodb_flush_method = O_DIRECT 121 | 122 | # 123 | # * Security Features 124 | # 125 | # Read the manual, too, if you want chroot! 126 | # = /var/lib/mysql/ 127 | # 128 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 129 | # 130 | # ssl-ca=/etc/mysql/cacert.pem 131 | # ssl-cert=/etc/mysql/server-cert.pem 132 | # ssl-key=/etc/mysql/server-key.pem 133 | 134 | # 135 | # * Galera-related settings 136 | # 137 | [galera] 138 | # Mandatory settings 139 | #wsrep_on =ON 140 | #wsrep_provider = 141 | #wsrep_cluster_address = 142 | #binlog_format =row 143 | #default_storage_engine =InnoDB 144 | #innodb_autoinc_lock_mode =2 145 | # 146 | # Allow server to accept connections on all interfaces. 147 | # 148 | #bind-address =0.0.0.0 149 | # 150 | # Optional setting 151 | #wsrep_slave_threads =1 152 | #innodb_flush_log_at_trx_commit =0 153 | 154 | [mysqldump] 155 | quick 156 | quote-names 157 | max_allowed_packet = 16M 158 | 159 | [mysql] 160 | #no-auto-rehash # faster start of mysql but no tab completion 161 | 162 | [isamchk] 163 | key_buffer = 16M 164 | 165 | # 166 | # * IMPORTANT: Additional settings that can override those from this file! 167 | # The files must end with '.cnf', otherwise they'll be ignored. 168 | # 169 | 170 | ## Include .conf files 171 | !includedir {{CONFIG_CUSTOM_PATH}} -------------------------------------------------------------------------------- /install/assets/mariadb/standard.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | port = 3306 3 | socket = {{SOCKET_PATH}}/{{SOCKET_FILE}} 4 | default-character-set = {{DB_CHARACTER_SET}} 5 | 6 | [mysqld_safe] 7 | socket = {{SOCKET_PATH}}/{{SOCKET_FILE}} 8 | nice = 0 9 | 10 | [mysqld] 11 | port = {{LISTEN_PORT}} 12 | socket = {{SOCKET_PATH}}/{{SOCKET_FILE}} 13 | bulk_insert_buffer_size = 16M 14 | character-set-client-handshake = FALSE 15 | character-set-server = {{DB_CHARACTER_SET}} 16 | collation-server = {{DB_COLLATION}} 17 | connect_timeout = 5 18 | max_connections = 100 19 | max_heap_table_size = 32M 20 | tmp_table_size = 32M 21 | wait_timeout = 600 22 | 23 | ### MyISAM 24 | expire_logs_days = 10 25 | key_buffer_size = 128M 26 | long_query_time = 10 27 | max_allowed_packet = 16M 28 | myisam_recover_options = BACKUP 29 | myisam_sort_buffer_size = 512M 30 | net_buffer_length = 16K 31 | query_cache_limit = 128K 32 | query_cache_size = 64M 33 | read_buffer_size = 2M 34 | read_rnd_buffer_size = 1M 35 | skip-external-locking 36 | general_log = 0 37 | general_log_file = {{LOG_PATH}}/{{LOG_FILE_GENERAL_QUERY}} 38 | log_error = {{LOG_PATH}}/{{LOG_FILE_ERROR}} 39 | log_warnings = 3 40 | slow_query_log = 0 41 | slow_query_log_file = {{LOG_PATH}}/{{LOG_FILE_SLOW_QUERY}} 42 | sort_buffer_size = 4M 43 | table_open_cache = 400 44 | 45 | ### InnoDB 46 | ### 47 | #### InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 48 | default_storage_engine = InnoDB 49 | # you can't just change log file size, requires special procedure 50 | #innodb_log_file_size = 50M 51 | innodb_buffer_pool_size = 256M 52 | innodb_file_per_table = 1 53 | innodb_flush_method = fsync 54 | innodb_io_capacity = 400 55 | innodb_log_buffer_size = 8M 56 | innodb_open_files = 400 57 | 58 | # Point the following paths to different dedicated disks 59 | #tmpdir = /tmp/ 60 | 61 | ### Replication 62 | # Replication Master Server (default) 63 | # binary logging is required for replication 64 | #log-bin = mysql-bin 65 | 66 | # binary logging format - mixed recommended 67 | #binlog_format = mixed 68 | #max_binlog_size = 100M 69 | 70 | # required unique id between 1 and 2^32 - 1 71 | # defaults to 1 if master-host is not set 72 | # but will not function as a master if omitted 73 | server-id = 1 74 | 75 | [mysqldump] 76 | max_allowed_packet = 16M 77 | quick 78 | quote-names 79 | 80 | [mysql] 81 | no-auto-rehash 82 | default-character-set = {{DB_CHARACTER_SET}} 83 | 84 | [myisamchk] 85 | key_buffer_size = 20M 86 | sort_buffer_size = 20M 87 | read_buffer = 2M 88 | write_buffer = 2M 89 | 90 | [mysqlhotcopy] 91 | interactive-timeout 92 | 93 | ## Include .conf files 94 | !includedir {{CONFIG_CUSTOM_PATH}} -------------------------------------------------------------------------------- /install/etc/cont-init.d/10-mariadb: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | 3 | source /assets/functions/00-container 4 | prepare_service 5 | # shellcheck disable=SC2034 6 | PROCESS_NAME="mariadb" 7 | 8 | bootstrap_filesystem 9 | bootstrap_variables 10 | configure_mariadb 11 | print_notice "Initializing MariaDB - Please wait.." 12 | initialize_mariadb 13 | create_databases 14 | configure_monitoring 15 | 16 | liftoff 17 | -------------------------------------------------------------------------------- /install/etc/cont-init.d/20-mariadb-backup: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | 3 | source /assets/functions/00-container 4 | prepare_service 5 | prepare_service 03-monitoring 6 | # shellcheck disable=SC2034 7 | PROCESS_NAME="mariadb-backup" 8 | output_off 9 | 10 | if var_true "${DB_BACKUP}" ; then 11 | print_notice "Enabling scheduled backups" 12 | backup_bootstrap_variables 13 | backup_sanity_test 14 | backup_setup_mode 15 | create_zabbix dbbackup 16 | else 17 | service_stop 20-mariadb-backup 18 | fi 19 | 20 | liftoff 21 | -------------------------------------------------------------------------------- /install/etc/fluent-bit/parsers.d/mariadb.conf: -------------------------------------------------------------------------------- 1 | [PARSER] 2 | Name mariadb-error 3 | Format regex 4 | Regex ^(?