mirror of
https://github.com/fradelg/docker-mysql-cron-backup.git
synced 2024-11-01 08:31:45 +01:00
log crond output, remove 1000 userid
This commit is contained in:
parent
33c570f26d
commit
89bb6f185e
3 changed files with 10 additions and 8 deletions
10
Dockerfile
10
Dockerfile
|
@ -3,7 +3,9 @@ RUN apk -U add openssl git
|
|||
|
||||
ARG DOCKERIZE_VERSION=v0.6.1
|
||||
WORKDIR /go/src/github.com/jwilder
|
||||
RUN git clone https://github.com/jwilder/dockerize.git && cd dockerize && git checkout ${DOCKERIZE_VERSION}
|
||||
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
|
||||
|
@ -31,11 +33,11 @@ ENV CRON_TIME="0 3 * * sun" \
|
|||
TIMEOUT="10s"
|
||||
|
||||
COPY ["run.sh", "backup.sh", "restore.sh", "/"]
|
||||
RUN mkdir /backup && \
|
||||
RUN mkdir /backup && \
|
||||
chmod 777 /backup && \
|
||||
chmod 755 /run.sh /backup.sh /restore.sh && \
|
||||
touch /mysql_backup.log && \
|
||||
chmod 666 /mysql_backup.log && \
|
||||
adduser -S -u 1000 -g 100 cronuser
|
||||
chmod 666 /mysql_backup.log
|
||||
|
||||
VOLUME ["/backup"]
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ do
|
|||
gzip "-$GZIP_LEVEL" -f "$FILENAME"
|
||||
echo "==> Creating symlink to latest backup: $(basename "$FILENAME".gz)"
|
||||
rm "$LATEST" 2> /dev/null
|
||||
cd /backup || exit && ln -s "$(basename "$FILENAME".gz)" "$(basename "$LATEST")" && cd - || exit
|
||||
cd /backup || exit && ln -s "$(basename "$FILENAME".gz)" "$(basename "$LATEST")"
|
||||
DB_COUNTER=$(( DB_COUNTER + 1 ))
|
||||
else
|
||||
rm -rf "$FILENAME"
|
||||
|
|
6
run.sh
6
run.sh
|
@ -11,10 +11,10 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then
|
|||
echo "waiting database container..."
|
||||
sleep 1
|
||||
done
|
||||
find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh
|
||||
find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh
|
||||
fi
|
||||
|
||||
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf
|
||||
crontab /tmp/crontab.conf
|
||||
echo "=> Running cron task manager"
|
||||
exec crond -f
|
||||
echo "=> Running cron task manager in foreground"
|
||||
exec crond -f -l 8 -L /mysql_backup.log
|
||||
|
|
Loading…
Reference in a new issue