This commit is contained in:
Audrey Jensen 2025-04-02 15:00:24 -05:00
commit 52a9d68e6b
Signed by: audrey
SSH Key Fingerprint: SHA256:k+6b1AGMt7Q6374OfeAXUFNe0eFpsUt6eV4biffF06U
2 changed files with 31 additions and 0 deletions

27
backup.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
echo "Beginning Hot-Backup of database..."
# Check if MYSQL_HOST is defined
if [ -z "$MYSQL_HOST" ]; then
echo "Error: MYSQL_HOST is not defined."
exit 1
fi
# Check if MYSQL_ROOT_PASS is defined
if [ -z "$MYSQL_ROOT_PASS" ]; then
echo "Error: MYSQL_ROOT_PASS is not defined."
exit 1
fi
# Check if BACKUP_NAME is defined
if [ -z "$BACKUP_NAME" ]; then
export BACKUP_NAME=$MYSQL_HOST
fi
#Figure out what to name the out file
if $APPEND_DATE; then
current_date=$(date +"%Y-%m-%d")
FILENAME="$BACKUP_NAME($current_date).sql"
else
FILENAME="$BACKUP_NAME.sql"
fi
mysqldump -u root --password=$MYSQL_ROOT_PASS --host=$MYSQL_HOST --all-databases > "/backup/$FILENAME.sql"

4
dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM mysql:latest
COPY backup.sh /usr/local/bin/
RUN chmod +x /usr/loca/bin/backup.sh
CMD ["cron","-f"]