AgentCC@tg says to 電訊台
backup_mysql=yes mysql_export_location=/home/mysql_backup/ mysql_location=/var/lib/mysql mysql_password=123456 now=date +%Y-%m-%d\ %H:%M:%S if [ "$backup_mysql" == "yes" ]; then if [ ! -f $mysql_export_location ]; then mkdir -p $mysql_export_location fi echo "Export Database start at: $now" for database in ls -l $mysql_location | grep drwx | awk '{print $9}' ; do /usr/bin/mysqldump -u root --password=$mysql_password $database > $mysql_export_location$database.sql done now=date +%Y-%m-%d\ %H:%M:%S echo "Export Database stop at: $now" >> $backup_status fi