full-system-backup: add mysql privileges

This commit is contained in:
Olaf Rempel 2010-03-14 12:57:19 +01:00
parent d72775ecb0
commit ed786ffcf1
1 changed files with 19 additions and 6 deletions

View File

@ -179,14 +179,27 @@ for name in $BACKUPS; do
auth="-u${user} -p${pass}"
[ -n "$pass" ] || auth="-u ${user}"
if [ -z "$db_list" ]; then
db_list=$(echo "show databases;" | /usr/bin/mysql ${auth} -r --column-name=FALSE)
fi
mysql_cmd="/usr/bin/mysql ${auth} -N"
mysql_schema_dump="/usr/bin/mysqldump ${auth} --opt --all --no-data"
mysql_data_dump="/usr/bin/mysqldump ${auth} --opt --add-locks=FALSE --no-create-info"
created_mysql_files=""
if [ -z "$db_list" ]; then
db_list=$(echo "SHOW databases;" | $mysql_cmd)
fi
echo " privileges" >&2
sql="SELECT DISTINCT CONCAT(\"'\", user, \"'@'\", host, \"'\") FROM mysql.user ORDER BY user, host;"
db_accounts=$(echo $sql | $mysql_cmd)
for account in $db_accounts; do
sql="SHOW GRANTS FOR $account;"
echo "-- $sql"
echo $sql | $mysql_cmd
echo
done >> ${tmpdir}/privileges.sql
created_mysql_files="privileges.sql"
for db in $db_list; do
echo " database $db" >&2
@ -219,7 +232,7 @@ done
# store a log (only when not debugging)
if [ -z "$DEBUG" ]; then
cat ${tmpdir}/msg | storage_put ${BACKUP_PREFIX}.log
cat ${tmpdir}/msg | storage_put ${BACKUP_PREFIX}.log none
created_files="$created_files ${BACKUP_PREFIX}.log"
fi