mysqldump 脚本

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/sh
if [ -z "$QUERY_STRING" ]
then
	echo "Content-type: text/html"
	echo
	echo "Dump a database <br />"
	for db in `echo "show databases" | mysql -uXXXX -pXXXXX`
	do 
		if [ "$db" != "Database" ]
		then
			echo "Dump : <a href='?$db'>$db</a> <br />"
		fi
	done
else
	echo "Content-type: application/x-sql"
	echo "Content-Disposition: attachment; filename=$QUERY_STRING-`date +%Y%m%d%H%M%S`.sql"
	echo
	mysqldump -uXXXX -pXXXXX $QUERY_STRING
fi