Skip to content

Commit d3cf0b5

Browse files
committed
update to latest debian and mysql client, remove SCHEDULE/go-cron
1 parent 7fad196 commit d3cf0b5

File tree

5 files changed

+23
-47
lines changed

5 files changed

+23
-47
lines changed

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
FROM alpine:latest
2-
LABEL maintainer="Johannes Schickling <schickling.j@gmail.com>"
3-
4-
ADD install.sh install.sh
5-
RUN sh install.sh && rm install.sh
1+
FROM debian:latest
62

73
ENV MYSQLDUMP_OPTIONS --quote-names --quick --add-drop-table --add-locks --allow-keywords --disable-keys --extended-insert --single-transaction --create-options --comments --net_buffer_length=16384
8-
ENV MYSQLDUMP_DATABASE --all-databases
4+
ENV MYSQLDUMP_DATABASE **None**
95
ENV MYSQL_HOST **None**
106
ENV MYSQL_PORT 3306
117
ENV MYSQL_USER **None**
@@ -19,9 +15,17 @@ ENV S3_S3V4 no
1915
ENV S3_PREFIX 'backup'
2016
ENV S3_FILENAME **None**
2117
ENV MULTI_FILES no
22-
ENV SCHEDULE **None**
2318

24-
ADD run.sh run.sh
25-
ADD backup.sh backup.sh
19+
# install mysqldump, pip, awscli
20+
RUN apt-get update && \
21+
apt-get install -y mariadb-client-10.3 python3 python3-pip && \
22+
pip3 install awscli && \
23+
apt-get autoremove -y && \
24+
apt-get remove -y python3-pip && \
25+
apt-get clean && \
26+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
27+
28+
ADD run.sh backup.sh /
29+
RUN chmod +x /run.sh /backup.sh
2630

27-
CMD ["sh", "run.sh"]
31+
CMD ["sh", "/run.sh"]

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
33
# mysql-backup-s3
44

5-
Backup MySQL to S3 (supports periodic backups & mutli files)
5+
Backup MySQL to S3 (supports periodic backups & mutli files).
6+
7+
Updated to use a Debian base image with the latest MySQL Client tools, removed support for `SCHEDULE` using go-cron.
68

79
## Basic usage
810

@@ -27,10 +29,4 @@ $ docker run -e S3_ACCESS_KEY_ID=key -e S3_SECRET_ACCESS_KEY=secret -e S3_BUCKET
2729
- `S3_ENDPOINT` the AWS Endpoint URL, for S3 Compliant APIs such as [minio](https://minio.io) (default: none)
2830
- `S3_S3V4` set to `yes` to enable AWS Signature Version 4, required for [minio](https://minio.io) servers (default: no)
2931
- `MULTI_FILES` Allow to have one file per database if set `yes` default: no)
30-
- `SCHEDULE` backup schedule time, see explainatons below
31-
32-
### Automatic Periodic Backups
33-
34-
You can additionally set the `SCHEDULE` environment variable like `-e SCHEDULE="@daily"` to run the backup automatically.
3532

36-
More information about the scheduling can be found [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules).

backup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ if [ "${S3_BUCKET}" == "**None**" ]; then
1515
exit 1
1616
fi
1717

18+
if [ "${MYSQLDUMP_DATABASE}" == "**None**" ]; then
19+
echo "You need to set the MYSQLDUMP_DATABASE environment variable (database name OR --all-databases)."
20+
exit 1
21+
fi
22+
1823
if [ "${MYSQL_HOST}" == "**None**" ]; then
1924
echo "You need to set the MYSQL_HOST environment variable."
2025
exit 1

install.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

run.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@ if [ "${S3_S3V4}" = "yes" ]; then
66
aws configure set default.s3.signature_version s3v4
77
fi
88

9-
if [ "${SCHEDULE}" = "**None**" ]; then
10-
sh backup.sh
11-
else
12-
exec go-cron "$SCHEDULE" /bin/sh backup.sh
13-
fi
9+
sh backup.sh

0 commit comments

Comments
 (0)