mirror of
https://github.com/fradelg/docker-mysql-cron-backup.git
synced 2025-01-18 16:22:33 +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
|
ARG DOCKERIZE_VERSION=v0.6.1
|
||||||
WORKDIR /go/src/github.com/jwilder
|
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
|
WORKDIR /go/src/github.com/jwilder/dockerize
|
||||||
RUN go get github.com/robfig/glock
|
RUN go get github.com/robfig/glock
|
||||||
|
@ -31,11 +33,11 @@ ENV CRON_TIME="0 3 * * sun" \
|
||||||
TIMEOUT="10s"
|
TIMEOUT="10s"
|
||||||
|
|
||||||
COPY ["run.sh", "backup.sh", "restore.sh", "/"]
|
COPY ["run.sh", "backup.sh", "restore.sh", "/"]
|
||||||
RUN mkdir /backup && \
|
RUN mkdir /backup && \
|
||||||
|
chmod 777 /backup && \
|
||||||
chmod 755 /run.sh /backup.sh /restore.sh && \
|
chmod 755 /run.sh /backup.sh /restore.sh && \
|
||||||
touch /mysql_backup.log && \
|
touch /mysql_backup.log && \
|
||||||
chmod 666 /mysql_backup.log && \
|
chmod 666 /mysql_backup.log
|
||||||
adduser -S -u 1000 -g 100 cronuser
|
|
||||||
|
|
||||||
VOLUME ["/backup"]
|
VOLUME ["/backup"]
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ do
|
||||||
gzip "-$GZIP_LEVEL" -f "$FILENAME"
|
gzip "-$GZIP_LEVEL" -f "$FILENAME"
|
||||||
echo "==> Creating symlink to latest backup: $(basename "$FILENAME".gz)"
|
echo "==> Creating symlink to latest backup: $(basename "$FILENAME".gz)"
|
||||||
rm "$LATEST" 2> /dev/null
|
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 ))
|
DB_COUNTER=$(( DB_COUNTER + 1 ))
|
||||||
else
|
else
|
||||||
rm -rf "$FILENAME"
|
rm -rf "$FILENAME"
|
||||||
|
|
6
run.sh
6
run.sh
|
@ -11,10 +11,10 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then
|
||||||
echo "waiting database container..."
|
echo "waiting database container..."
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
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
|
fi
|
||||||
|
|
||||||
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf
|
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf
|
||||||
crontab /tmp/crontab.conf
|
crontab /tmp/crontab.conf
|
||||||
echo "=> Running cron task manager"
|
echo "=> Running cron task manager in foreground"
|
||||||
exec crond -f
|
exec crond -f -l 8 -L /mysql_backup.log
|
||||||
|
|
Loading…
Reference in a new issue