From ae4ca54e9f4f7250b9fd2998da3be3cbd3fd8889 Mon Sep 17 00:00:00 2001 From: Tobias Janke <git@tojanke.de> Date: Thu, 5 Dec 2024 14:46:31 +0100 Subject: [PATCH] Add option to remove duplicates using fdupes --- Dockerfile | 3 ++- README.md | 1 + backup.sh | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 29cae87..fb17ac7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,8 @@ RUN apk add --update \ mysql-client \ bzip2 \ 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 6c39e9f..4a7d1f6 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Container is **Healthy** after the database init phase, that is after `INIT_BACK - `BZIP2_LEVEL`: Specify the level of bzip2 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 bzip2. - `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 e890b78..236f879 100755 --- a/backup.sh +++ b/backup.sh @@ -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