Skip to content

Commit 9e4d7f4

Browse files
author
Katherine
committed
Echo error if database file is not created
1 parent 0b1fc4b commit 9e4d7f4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: linux/backup_mysqldb.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ do
3131

3232
#the file
3333
SQLFILE=${cpath}/${sqldbs[$i]}_$suffix.sql.gz
34-
mysqldump -c -h $mysqlhost --user ${usernames[$i]} --password=${passwords[$i]} ${sqldbs[$i]} | gzip > $SQLFILE
35-
36-
scp ${SQLFILE} ${backup_user}@${backup_server}:~/dir_backups/database
37-
34+
35+
if mysqldump -c -h $mysqlhost --user ${usernames[$i]} --password=${passwords[$i]} ${sqldbs[$i]} | gzip > $SQLFILE
36+
then
37+
scp ${SQLFILE} ${backup_user}@${backup_server}:~/dir_backups/database
38+
else
39+
echo "[!!ERROR!!] Failed to create the file $SQLFILE"
40+
fi
41+
42+
3843
#on the server that keeps the database files, add this cron rule. If you want to keep more than 10 days of data, just change 10.
3944
#0 0 * * * find /home/user/dir_backups/database/* -type f -mtime +10 -exec rm {} \;
4045

0 commit comments

Comments
 (0)