This shell script needs to have execute permissions. You’ll also need to modify the SQLUSR and SQLPWD with the values of a user that has read permissions on all databases you want it to backup. This script needs to be run as a user who has write permissions to BKPDIR.
#!/bin/bash
SQLUSR=sql_username
SQLPWD=sql_password
BKPDIR=/my/backups/sql/
RDATE=`date +%Y%m%d`
mysql -u $SQLUSR -p$SQLPWD -e "show databases;" -s > tmplst.tmp
exec 6
do
FN1="mysqldump -u $SQLUSR -p$SQLPWD "$dta" | gzip > “$BKPDIR$dta.$RDATE”.sql.gz”
echo $FN1 >> bkup_cmd.tmp
done
exec 6<&-
fi
source bkup_cmd.tmp
rm tmplst.tmp
rm bkup_cmd.tmp
You must be logged in to post a comment.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jan | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
25 queries. 0.142 seconds