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
12 changes: 7 additions & 5 deletions docker/backup/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM python:3.12
FROM mysql:8.4

# Install MySQL client.
RUN apt-get update && apt-get install -y mariadb-client
# Use the official MySQL dump client for MySQL generated-column support.
# Install Python and gzip for the S3 client and compressed backups.
RUN microdnf install -y python3-pip gzip && microdnf clean all

# Install S3 client.
RUN pip install s3cmd
RUN pip3 install --no-cache-dir s3cmd

# Copy files.
COPY scripts/backup.sh ./

# Run backup task.
CMD bash backup.sh
ENTRYPOINT []
CMD ["bash", "backup.sh"]
2 changes: 1 addition & 1 deletion scripts/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ while true; do
SQL_FILE=$(date '+%Y-%m-%d.%H').sql.gz

# Dump and compress database in one stream
mysqldump --no-tablespaces -h ${MYSQL_HOST:=127.0.0.1} -u ${MYSQL_USER:=gorse} -p${MYSQL_PASSWORD:=gorse_pass} --ssl-verify-server-cert=0 ${MYSQL_DATABASE:=gorse} users items feedback flask_dance_oauth | gzip > $SQL_FILE
mysqldump --no-tablespaces -h ${MYSQL_HOST:=127.0.0.1} -u ${MYSQL_USER:=gorse} -p${MYSQL_PASSWORD:=gorse_pass} --ssl-mode=PREFERRED ${MYSQL_DATABASE:=gorse} users items feedback flask_dance_oauth | gzip > $SQL_FILE

# Upload SQL file
s3cmd --access_key=$S3_ACCESS_KEY \
Expand Down
Loading