From bcf82ae4e6c1f42aa9416f5e2c64d316d176bbd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 04:59:56 +0000 Subject: [PATCH 01/24] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> --- .github/workflows/image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 6705901..88f1311 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout the code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Test Bash scripts run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test build: @@ -21,7 +21,7 @@ jobs: needs: test steps: - name: Checkout the code - uses: actions/checkout@v3 + uses: actions/checkout@v4 # https://github.com/docker/setup-qemu-action - name: Set up QEMU uses: docker/setup-qemu-action@v2 From 895f17a082527c96b7b9a1a5e4a84fda7747cf95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 05:03:02 +0000 Subject: [PATCH 02/24] Bump docker/setup-buildx-action from 2 to 3 Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> --- .github/workflows/image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 88f1311..80d5cc9 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -27,7 +27,7 @@ jobs: uses: docker/setup-qemu-action@v2 # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Get latest release version number id: docker-tag uses: yuya-takeyama/docker-tag-from-github-ref-action@v1 From 554424bbc5e3dfc8ca619ed8d77c42f595aa307d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Sep 2023 17:07:34 +0000 Subject: [PATCH 03/24] Bump docker/setup-qemu-action from 2 to 3 Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-qemu-action/releases) - [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-qemu-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> --- .github/workflows/image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 80d5cc9..b472c36 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v4 # https://github.com/docker/setup-qemu-action - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From 4be928f6d021ca845d199ce921ce2a93d6cdc3bd Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Fri, 15 Sep 2023 19:56:06 +0200 Subject: [PATCH 04/24] Upgrade dockerize to 0.7.0 (#110) * update dockerize docker instructions * login to docker hub using action --- .github/workflows/image.yml | 5 ++++- Dockerfile | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index b472c36..e639e5f 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -32,7 +32,10 @@ jobs: id: docker-tag uses: yuya-takeyama/docker-tag-from-github-ref-action@v1 - name: Login to Docker Hub - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Build multiarch image run: | docker buildx build --push \ diff --git a/Dockerfile b/Dockerfile index fdc2638..95ad9bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ -FROM golang:1.15.8-alpine3.12 AS binary +FROM golang:1.20.4-alpine3.18 AS binary RUN apk -U add openssl git -ARG DOCKERIZE_VERSION=v0.6.1 +ARG DOCKERIZE_VERSION=v0.7.0 WORKDIR /go/src/github.com/jwilder RUN git clone https://github.com/jwilder/dockerize.git && \ cd dockerize && \ git checkout ${DOCKERIZE_VERSION} WORKDIR /go/src/github.com/jwilder/dockerize -RUN go get github.com/robfig/glock -RUN glock sync -n < GLOCKFILE -RUN go install +ENV GO111MODULE=on +RUN go mod tidy +RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . FROM alpine:3.18.3 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" From e52061d4fab332d3b07234a1a3914f82ba5a385c Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Sun, 17 Sep 2023 11:01:33 +0200 Subject: [PATCH 05/24] Test docker image before pushing to docker hub (#111) * update dockerize docker instructions * use go with alpine * login to docker hub using action too * test docker image before building * extract command from the entrypoint * change volume path * user docker compose run and cmd instead entrypoint --- .github/workflows/image.yml | 10 ++++++++++ Dockerfile | 2 +- restore.sh | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index e639e5f..1fe4d25 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -16,6 +16,16 @@ jobs: uses: actions/checkout@v4 - name: Test Bash scripts run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test + - name: Test image + env: + VOLUME_PATH: /tmp/mariadb + DATABASE_NAME: foo + MARIADB_ROOT_PASSWORD: abcd + run: | + docker-compose up -d mariadb + docker-compose run backup /backup.sh + docker-compose run backup /restore.sh /backup/latest.foo.sql.gz + docker-compose stop build: runs-on: ubuntu-22.04 needs: test diff --git a/Dockerfile b/Dockerfile index 95ad9bc..851a5c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,4 +44,4 @@ VOLUME ["/backup"] HEALTHCHECK --interval=2s --retries=1800 \ CMD stat /HEALTHY.status || exit 1 -ENTRYPOINT dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh \ No newline at end of file +CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh diff --git a/restore.sh b/restore.sh index 0607d6f..6c03634 100755 --- a/restore.sh +++ b/restore.sh @@ -13,6 +13,7 @@ if [ "$#" -ne 1 ] then echo "You must pass the path of the backup file to restore" + exit 1 fi set -o pipefail From 549f30ef6fd56011e1b19af82e979365497b1b60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 04:49:58 +0000 Subject: [PATCH 06/24] Bump alpine from 3.18.3 to 3.18.4 Bumps alpine from 3.18.3 to 3.18.4. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 851a5c2..55b0e95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.18.3 +FROM alpine:3.18.4 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From f8addec08ff1b25e5c8e800763803058b7732ad7 Mon Sep 17 00:00:00 2001 From: nikgli <niklagligorovski@outlook.com> Date: Thu, 2 Nov 2023 14:28:58 +0800 Subject: [PATCH 07/24] Fixed access denied (at least one of) the PROCESS privilege(s) is required error --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6627b0d..dad5be3 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,8 @@ services: - CRON_TIME=0 3 * * * # Make it small - GZIP_LEVEL=9 + # As of MySQL 8.0.21 this is needed + - MYSQLDUMP_OPTS=--no-tablespaces restart: unless-stopped volumes: From a84b82077fb52680f887dfc15701d3c0507f6d96 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 04:59:07 +0000 Subject: [PATCH 08/24] Bump alpine from 3.18.4 to 3.18.5 Bumps alpine from 3.18.4 to 3.18.5. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 55b0e95..5318e57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.18.4 +FROM alpine:3.18.5 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From 9c84748595070927a1d9e76d7bfc85fb1acc8368 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Dec 2023 04:20:17 +0000 Subject: [PATCH 09/24] Bump alpine from 3.18.5 to 3.19.0 Bumps alpine from 3.18.5 to 3.19.0. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5318e57..26e3c72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.18.5 +FROM alpine:3.19.0 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From d20b5ea8a9b1ddfb80519b28de4ed6375367c458 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 04:23:47 +0000 Subject: [PATCH 10/24] Bump alpine from 3.19.0 to 3.19.1 Bumps alpine from 3.19.0 to 3.19.1. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 26e3c72..60c89dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.19.0 +FROM alpine:3.19.1 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From efe543062965af7f8d0cb0b1fd12f6b1e8d41799 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 04:30:24 +0000 Subject: [PATCH 11/24] Bump alpine from 3.19.1 to 3.20.0 Bumps alpine from 3.19.1 to 3.20.0. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 60c89dd..ddbd6ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.19.1 +FROM alpine:3.20.0 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From 7fbc2fb79e1b4a0f5a63289edf88200fc204d284 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 04:44:44 +0000 Subject: [PATCH 12/24] Bump alpine from 3.20.0 to 3.20.1 Bumps alpine from 3.20.0 to 3.20.1. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ddbd6ab..c3fb7e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.20.0 +FROM alpine:3.20.1 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From 9e325e3ef7d0e9f4baf06c6d366bb7b60e7a8c14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 04:19:30 +0000 Subject: [PATCH 13/24] Bump alpine from 3.20.1 to 3.20.2 Bumps alpine from 3.20.1 to 3.20.2. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c3fb7e3..0c0de4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.20.1 +FROM alpine:3.20.2 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From 23cf857487cd668c1e3d16a8cf10570825a9cc50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 04:30:04 +0000 Subject: [PATCH 14/24] Bump alpine from 3.20.2 to 3.20.3 Bumps alpine from 3.20.2 to 3.20.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0c0de4c..51fbf16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.20.2 +FROM alpine:3.20.3 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From 353430ff83f7177125f011fdc7068d2c6af6279f Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Tue, 10 Sep 2024 19:25:10 +0200 Subject: [PATCH 15/24] move to docker v2 --- .github/workflows/image.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 1fe4d25..d1b827f 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -22,10 +22,10 @@ jobs: DATABASE_NAME: foo MARIADB_ROOT_PASSWORD: abcd run: | - docker-compose up -d mariadb - docker-compose run backup /backup.sh - docker-compose run backup /restore.sh /backup/latest.foo.sql.gz - docker-compose stop + docker compose up -d mariadb + docker compose run backup /backup.sh + docker compose run backup /restore.sh /backup/latest.foo.sql.gz + docker compose stop build: runs-on: ubuntu-22.04 needs: test @@ -50,4 +50,4 @@ jobs: run: | docker buildx build --push \ --tag fradelg/mysql-cron-backup:${{ steps.docker-tag.outputs.tag }} \ - --platform linux/amd64,linux/arm/v7,linux/arm64 . \ No newline at end of file + --platform linux/amd64,linux/arm/v7,linux/arm64 . From 07213e81358665a17117297f95104898989d0958 Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Tue, 10 Sep 2024 19:37:59 +0200 Subject: [PATCH 16/24] use service name for dns --- docker-compose.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index d0b693f..e154335 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,6 @@ version: "2" services: mariadb: image: mariadb:10 - container_name: my_mariadb expose: - 3306 volumes: @@ -21,7 +20,7 @@ services: volumes: - ${VOLUME_PATH}/backup:/backup environment: - - MYSQL_HOST=my_mariadb + - MYSQL_HOST=mariadb - MYSQL_USER=root - MYSQL_PASS=${MARIADB_ROOT_PASSWORD} - MAX_BACKUPS=1 @@ -30,4 +29,4 @@ services: restart: unless-stopped volumes: - data: \ No newline at end of file + data: From a715b4946cd805a0f26aba557b721904696e8c66 Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Tue, 10 Sep 2024 19:47:30 +0200 Subject: [PATCH 17/24] add health check --- docker-compose.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index e154335..6dfbf75 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,6 +2,7 @@ version: "2" services: mariadb: image: mariadb:10 + container_name: my_mariadb expose: - 3306 volumes: @@ -10,17 +11,23 @@ services: environment: - MYSQL_DATABASE=${DATABASE_NAME} - MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD} + - MYSQL_ALLOW_EMPTY_ROOT_PASSWORD=yes restart: unless-stopped + healthcheck: + test: ["CMD", "healthcheck.sh", "--su-mysql", "--connect"] + timeout: 5s + retries: 10 backup: build: . image: fradelg/mysql-cron-backup depends_on: - - mariadb + mariadb: + condition: service_healthy volumes: - ${VOLUME_PATH}/backup:/backup environment: - - MYSQL_HOST=mariadb + - MYSQL_HOST=my_mariadb - MYSQL_USER=root - MYSQL_PASS=${MARIADB_ROOT_PASSWORD} - MAX_BACKUPS=1 From dac06953c32e804bf39f6599dc6fc14f4c123464 Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Tue, 10 Sep 2024 19:52:19 +0200 Subject: [PATCH 18/24] do not mask docker username --- .github/workflows/image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index d1b827f..5827146 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -44,7 +44,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} + username: fradelg password: ${{ secrets.DOCKER_PASSWORD }} - name: Build multiarch image run: | From aebb29ab640d935698301a0412dbc3969429de2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 04:39:42 +0000 Subject: [PATCH 19/24] Bump alpine from 3.20.3 to 3.21.0 Bumps alpine from 3.20.3 to 3.21.0. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 51fbf16..e363c48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.20.3 +FROM alpine:3.21.0 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ From 823343381d42e055998106cb492ae18908cc8dc0 Mon Sep 17 00:00:00 2001 From: Tobias Janke <git@tojanke.de> Date: Sun, 8 Dec 2024 11:12:39 +0100 Subject: [PATCH 20/24] [Feature] Remove duplicate database dumps to save storage space (#127) * Replace gzip with deterministic bzip2 compression * Exclude comments from SQL dump * Add option to remove duplicates using fdupes * Revert change to bzip2 as gzip can be deterministic using no-name parameter --- Dockerfile | 3 ++- README.md | 1 + backup.sh | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 51fbf16..e6887c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,8 @@ RUN apk add --update \ mysql-client \ gzip \ openssl \ - mariadb-connector-c && \ + mariadb-connector-c \ + fdupes && \ rm -rf /var/cache/apk/* COPY --from=binary /go/bin/dockerize /usr/local/bin diff --git a/README.md b/README.md index dad5be3..16a2d65 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Container is **Healthy** after the database init phase, that is after `INIT_BACK - `GZIP_LEVEL`: Specify the level of gzip compression from 1 (quickest, least compressed) to 9 (slowest, most compressed), default is 6. - `USE_PLAIN_SQL`: If set, back up and restore plain SQL files without gzip. - `TZ`: Specify TIMEZONE in Container. E.g. "Europe/Berlin". Default is UTC. +- `REMOVE_DUPLICATES`: Use [fdupes](https://github.com/adrianlopezroche/fdupes) to remove duplicate database dumps If you want to make this image the perfect companion of your MySQL container, use [docker-compose](https://docs.docker.com/compose/). You can add more services that will be able to connect to the MySQL image using the name `my_mariadb`, note that you only expose the port `3306` internally to the servers and not to the host: diff --git a/backup.sh b/backup.sh index 747cd82..d7db8a7 100755 --- a/backup.sh +++ b/backup.sh @@ -29,13 +29,13 @@ do echo "==> Dumping database: $db" FILENAME=/backup/$DATE.$db.sql LATEST=/backup/latest.$db.sql - if mysqldump --single-transaction $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME" + if mysqldump --single-transaction --skip-comments $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME" then EXT= if [ -z "${USE_PLAIN_SQL}" ] then echo "==> Compressing $db with LEVEL $GZIP_LEVEL" - gzip "-$GZIP_LEVEL" -f "$FILENAME" + gzip "-$GZIP_LEVEL" -n -f "$FILENAME" EXT=.gz FILENAME=$FILENAME$EXT LATEST=$LATEST$EXT @@ -44,6 +44,11 @@ do echo "==> Creating symlink to latest backup: $BASENAME" rm "$LATEST" 2> /dev/null cd /backup || exit && ln -s "$BASENAME" "$(basename "$LATEST")" + if [ -n "$REMOVE_DUPLICATES" ] + then + echo "=> Removing duplicate database dumps" + fdupes -idN /backup/ + fi if [ -n "$MAX_BACKUPS" ] then # Execute the delete script, delete older backup or other custom delete script From dc253cd1ea27e6582500877137bc9e26143ee6b0 Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Sun, 8 Dec 2024 12:52:35 +0100 Subject: [PATCH 21/24] stick to client 10.11 version --- Dockerfile | 18 +++++++++--------- docker-compose.yaml | 11 ++++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 969c917..73a2588 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,17 +12,17 @@ ENV GO111MODULE=on RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /go/bin/dockerize . -FROM alpine:3.21.0 +FROM alpine:3.20.3 LABEL maintainer "Fco. Javier Delgado del Hoyo <frandelhoyo@gmail.com>" RUN apk add --update \ - tzdata \ - bash \ - mysql-client \ - gzip \ - openssl \ - mariadb-connector-c \ - fdupes && \ + tzdata \ + bash \ + gzip \ + openssl \ + mysql-client=~10.11 \ + mariadb-connector-c \ + fdupes && \ rm -rf /var/cache/apk/* COPY --from=binary /go/bin/dockerize /usr/local/bin @@ -43,6 +43,6 @@ RUN mkdir /backup && \ VOLUME ["/backup"] HEALTHCHECK --interval=2s --retries=1800 \ - CMD stat /HEALTHY.status || exit 1 + CMD stat /HEALTHY.status || exit 1 CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index 6dfbf75..5ac0e9d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,8 +1,9 @@ -version: "2" services: mariadb: - image: mariadb:10 + image: mariadb:10.11 container_name: my_mariadb + security_opt: + - seccomp:unconfined expose: - 3306 volumes: @@ -14,7 +15,7 @@ services: - MYSQL_ALLOW_EMPTY_ROOT_PASSWORD=yes restart: unless-stopped healthcheck: - test: ["CMD", "healthcheck.sh", "--su-mysql", "--connect"] + test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect" ] timeout: 5s retries: 10 @@ -34,6 +35,6 @@ services: - INIT_BACKUP=1 - CRON_TIME=0 0 * * * restart: unless-stopped - -volumes: + +volumes: data: From cff595e6340c44ac53132dd4fed93872f85f0ca4 Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <frandelhoyo@gmail.com> Date: Sun, 8 Dec 2024 13:56:43 +0100 Subject: [PATCH 22/24] disable skip comments only when needed --- backup.sh | 8 +++++++- docker-compose.yaml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index d7db8a7..ead820e 100755 --- a/backup.sh +++ b/backup.sh @@ -29,7 +29,13 @@ do echo "==> Dumping database: $db" FILENAME=/backup/$DATE.$db.sql LATEST=/backup/latest.$db.sql - if mysqldump --single-transaction --skip-comments $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME" + BASIC_OPTS="--single-transaction" + if [ -n "$REMOVE_DUPLICATES" ] + then + echo "WARNING: disabling comments in backup to remove deuplicate backups. Automatic database name detection won't work so set MYSQL_DATABASE on restore" + BASIC_OPTS="$BASIC_OPTS" --skip-comments + fi + if mysqldump $BASIC_OPTS $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME" then EXT= if [ -z "${USE_PLAIN_SQL}" ] diff --git a/docker-compose.yaml b/docker-compose.yaml index 5ac0e9d..64dcef0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -30,6 +30,7 @@ services: environment: - MYSQL_HOST=my_mariadb - MYSQL_USER=root + - MYSQL_DATABASE=${DATABASE_NAME} - MYSQL_PASS=${MARIADB_ROOT_PASSWORD} - MAX_BACKUPS=1 - INIT_BACKUP=1 From 8a15e59c1fef2a2f6f29f9839822b9e903691e0f Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <fradelg@Fcos-Air.home> Date: Mon, 9 Dec 2024 12:23:08 +0100 Subject: [PATCH 23/24] skip only timestamps when needed --- backup.sh | 5 ++--- docker-compose.yaml | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/backup.sh b/backup.sh index ead820e..499575d 100755 --- a/backup.sh +++ b/backup.sh @@ -32,8 +32,7 @@ do BASIC_OPTS="--single-transaction" if [ -n "$REMOVE_DUPLICATES" ] then - echo "WARNING: disabling comments in backup to remove deuplicate backups. Automatic database name detection won't work so set MYSQL_DATABASE on restore" - BASIC_OPTS="$BASIC_OPTS" --skip-comments + BASIC_OPTS="$BASIC_OPTS --skip-dump-date" fi if mysqldump $BASIC_OPTS $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME" then @@ -52,7 +51,7 @@ do cd /backup || exit && ln -s "$BASENAME" "$(basename "$LATEST")" if [ -n "$REMOVE_DUPLICATES" ] then - echo "=> Removing duplicate database dumps" + echo "==> Removing duplicate database dumps" fdupes -idN /backup/ fi if [ -n "$MAX_BACKUPS" ] diff --git a/docker-compose.yaml b/docker-compose.yaml index 64dcef0..5ac0e9d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -30,7 +30,6 @@ services: environment: - MYSQL_HOST=my_mariadb - MYSQL_USER=root - - MYSQL_DATABASE=${DATABASE_NAME} - MYSQL_PASS=${MARIADB_ROOT_PASSWORD} - MAX_BACKUPS=1 - INIT_BACKUP=1 From 1d3c439b654fa1d5400ccaf318d8b0ff8a051a1d Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" <fradelg@Fcos-Air.home> Date: Mon, 9 Dec 2024 12:32:31 +0100 Subject: [PATCH 24/24] split test and build jobs --- .github/workflows/{image.yml => build.yml} | 22 +----------------- .github/workflows/test.yml | 26 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) rename .github/workflows/{image.yml => build.yml} (59%) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/image.yml b/.github/workflows/build.yml similarity index 59% rename from .github/workflows/image.yml rename to .github/workflows/build.yml index 5827146..fab409a 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/build.yml @@ -1,34 +1,14 @@ + name: build docker image on: - workflow_dispatch: push: - branches: - - "**" tags: - "**" jobs: - test: - runs-on: ubuntu-22.04 - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - name: Test Bash scripts - run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test - - name: Test image - env: - VOLUME_PATH: /tmp/mariadb - DATABASE_NAME: foo - MARIADB_ROOT_PASSWORD: abcd - run: | - docker compose up -d mariadb - docker compose run backup /backup.sh - docker compose run backup /restore.sh /backup/latest.foo.sql.gz - docker compose stop build: runs-on: ubuntu-22.04 - needs: test steps: - name: Checkout the code uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4460983 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: build docker image + +on: + workflow_dispatch: + push: + branches: + - "**" + +jobs: + test: + runs-on: ubuntu-22.04 + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - name: Test Bash scripts + run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test + - name: Test image + env: + VOLUME_PATH: /tmp/mariadb + DATABASE_NAME: foo + MARIADB_ROOT_PASSWORD: abcd + run: | + docker compose up -d mariadb + docker compose run backup /backup.sh + docker compose run backup /restore.sh /backup/latest.foo.sql.gz + docker compose stop