init
This commit is contained in:
commit
52a9d68e6b
27
backup.sh
Normal file
27
backup.sh
Normal 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
4
dockerfile
Normal 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"]
|
||||
Loading…
x
Reference in New Issue
Block a user