清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/bin/bash ########################################################################################## # NOTE: # The readme text is written by chinese. # Please see this scripts in your chinese System. # The test system is Ubuntu12.04 # # # This Scripts all rights reserved deserved by MickeyZZC # Copyright © 2013 # #2013-08-16:add remote backup #2013-08-19:add ftp backup # ########################################################################################## PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH clear; username="" passwd="" mysqlhost="" backuppath="" #备份数据库 function mysqlbackup() { #把生产线上的数据库赋值给数组变量 mysqldata=`mysql -h$mysqlhost -u$username -p$passwd -e"show databases"|grep -vE "mysql|information_schema|performance_schema|Database"` for i in ${mysqldata[@]} do #先清理空间后在备份会比较稳当一点 find $backuppath -name $i\_*.zip -type f -mtime +7 -exec rm {} \; #备份后压缩保存 mysqldump --opt -h$mysqlhost -u$username -p$passwd $i |gzip > $backuppath/$i\_$(date +%Y%m%d%H%M).zip done } function dataftp() { ftphost='' ftpusr='' ftpd='' ftp -v -n $ftphost<<! user $ftpusr $ftpd binary passive lcd $backuppath cd / mput *$(date +%Y%m%d)* close bye ! } #调用mysqlbackup mysqlbackup #调用FTP上传备份 dataftp