full-system-backup: add mysql privileges
This commit is contained in:
parent
d72775ecb0
commit
ed786ffcf1
@ -179,14 +179,27 @@ for name in $BACKUPS; do
|
|||||||
auth="-u${user} -p${pass}"
|
auth="-u${user} -p${pass}"
|
||||||
[ -n "$pass" ] || auth="-u ${user}"
|
[ -n "$pass" ] || auth="-u ${user}"
|
||||||
|
|
||||||
if [ -z "$db_list" ]; then
|
mysql_cmd="/usr/bin/mysql ${auth} -N"
|
||||||
db_list=$(echo "show databases;" | /usr/bin/mysql ${auth} -r --column-name=FALSE)
|
|
||||||
fi
|
|
||||||
|
|
||||||
mysql_schema_dump="/usr/bin/mysqldump ${auth} --opt --all --no-data"
|
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"
|
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
|
for db in $db_list; do
|
||||||
echo " database $db" >&2
|
echo " database $db" >&2
|
||||||
|
|
||||||
@ -219,7 +232,7 @@ done
|
|||||||
|
|
||||||
# store a log (only when not debugging)
|
# store a log (only when not debugging)
|
||||||
if [ -z "$DEBUG" ]; then
|
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"
|
created_files="$created_files ${BACKUP_PREFIX}.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user