add new env vars and error handling
This commit is contained in:
parent
20b9100624
commit
ff55c5e35e
11
backup.sh
11
backup.sh
@ -1,14 +1,14 @@
|
||||
#!/bin/bash
|
||||
echo "Beginning Hot-Backup of database..."
|
||||
echo "Beginning Hot-Backup of database..." >> /var/log/cron.log
|
||||
# Check if MYSQL_HOST is defined
|
||||
if [ -z "$MYSQL_HOST" ]; then
|
||||
echo "Error: MYSQL_HOST is not defined."
|
||||
echo "Error: MYSQL_HOST is not defined." >> /var/log/cron.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if MYSQL_ROOT_PASS is defined
|
||||
if [ -z "$MYSQL_ROOT_PASS" ]; then
|
||||
echo "Error: MYSQL_ROOT_PASS is not defined."
|
||||
if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
|
||||
echo "Error: MYSQL_ROOT_PASS is not defined." >> /var/log/cron.log
|
||||
exit 1
|
||||
fi
|
||||
# Check if BACKUP_NAME is defined
|
||||
@ -24,4 +24,5 @@ else
|
||||
FILENAME="$BACKUP_NAME.sql"
|
||||
fi
|
||||
|
||||
mysqldump -u root --password=$MYSQL_ROOT_PASS --host=$MYSQL_HOST --all-databases > "/backup/$FILENAME.sql"
|
||||
mysqldump -u root --password=$MYSQL_ROOT_PASSWORD --host=$MYSQL_HOST --all-databases > "/backup/$FILENAME"
|
||||
echo "MySQL backup complete" >> /var/log/cron.log
|
||||
Loading…
x
Reference in New Issue
Block a user