mirror of
https://github.com/fradelg/docker-mysql-cron-backup.git
synced 2025-01-18 16:22:33 +01:00
Compare commits
2 commits
d5d98e5a7c
...
cff595e634
Author | SHA1 | Date | |
---|---|---|---|
|
cff595e634 | ||
|
dc253cd1ea |
3 changed files with 23 additions and 15 deletions
18
Dockerfile
18
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
|
||||
|
|
|
@ -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}" ]
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -29,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
|
||||
|
|
Loading…
Reference in a new issue