Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Build
#
FROM --platform=$TARGETPLATFORM mysql/mysql-server:8.0.32

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker_image_job

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker_image_job

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/
ARG TARGETPLATFORM

WORKDIR /a
Expand All @@ -12,13 +12,17 @@

# Add Tini
# See https://github.com/krallin/tini for the further details
ENV TINI_VERSION v0.18.0

Check warning on line 15 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker_image_job

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 15 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker_image_job

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
RUN PLATFORM="$(echo $TARGETPLATFORM | cut -d/ -f2)" &&\
curl -sLfo /tini "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${PLATFORM}"
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]

RUN microdnf install -y gzip
RUN microdnf install -y gzip cronie

# Register a cronjob
COPY crontab .
RUN crontab crontab && rm crontab

# Install php
RUN microdnf install -y php-cli
Expand All @@ -33,6 +37,6 @@
RUN microdnf clean all

# Copy scripts
COPY docker-cmd /usr/local/bin/
COPY do-backup docker-cmd /usr/local/bin/

CMD ["/usr/local/bin/docker-cmd"]
1 change: 1 addition & 0 deletions crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 6 * * * /usr/local/bin/do-backup >> /tmp/log 2>&1
21 changes: 21 additions & 0 deletions do-backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail; IFS=$'\n\t'

FILE_NAME=$(date --iso-8601=minutes).sql.gz

# Dumps and compresses database, uploads backup file to AWS S3

for i in {1..5}; do
echo "Trying to dump and compress... $i/5"
nice -n 19 mysqldump --single-transaction femiwiki |
nice -n 19 gzip -9 > $FILE_NAME &&\
break || sleep 15
done

for i in {1..5}; do
echo "Trying to upload... $i/5"
nice -n 19 /usr/local/bin/aws s3 cp $FILE_NAME "s3://femiwiki-backups/mysql/${FILE_NAME}" &&\
break || sleep 15
done

rm $FILE_NAME
19 changes: 3 additions & 16 deletions docker-cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ password=$DB_PASSWORD
single-transaction
EOF

FILE_NAME=$(date --iso-8601=minutes).sql.gz

# Dumps and compresses database, uploads backup file to AWS S3

for i in {1..5}; do
echo "Trying to dump and compress... $i/5"
nice -n 19 mysqldump --single-transaction femiwiki |
nice -n 19 gzip -9 > $FILE_NAME &&\
break || sleep 15
done

for i in {1..5}; do
echo "Trying to upload... $i/5"
nice -n 19 /usr/local/bin/aws s3 cp $FILE_NAME "s3://femiwiki-backups/mysql/${FILE_NAME}" &&\
break || sleep 15
done
touch /tmp/log
crond
tail -f /tmp/log