日期:2014-05-16 浏览次数:20504 次
#!/bin/bash # X , sendmail hoodbc20117 ### Setting path ### BACKPATH="/data0/mysql_bak" DATE=`/bin/date "+%Y-%m-%d-%H-%M-%S"` zip -rq $BACKPATH/erp_$DATE.zip /data/htdocs/www/erp/ echo "erp all backup" | mutt -a $BACKPATH/erp_$DATE.zip -s "erp all backup" bluehood24@163.com find $BACKPATH -ctime +30 -name *.zip -delete
#!/bin/bash # hoodbc20117 ### database setting ### USER='root' PASSWORD='' HOST="127.0.0.1" DATABASES=(erp) ### Setting path ### MYSQLDUMP=/usr/local/webserver/mysql/bin/mysqldump BACKPATH="/data0/mysql_bak" DATE=`/bin/date "+%Y-%m-%d-%H-%M-%S"` for DATABASE in ${DATABASES[*]} do FILENAME="$DATABASE-$DATE" $MYSQLDUMP --add-drop-table --user $USER --password=$PASSWORD $DATABASE --lock-all-tables>> "$BACKPATH/$FILENAME.sql" done #tar zcf -r $BACKPATH/erp_$DATE.tar.gz ~/data/htdocs/www/erp #zip -rq $BACKPATH/erp_$DATE.zip /data/htdocs/www/erp/ zip -rq $BACKPATH/$FILENAME.zip $BACKPATH/$FILENAME.sql echo "erp db backup" | mutt -a $BACKPATH/$FILENAME.zip -s "erp db backup" bluehood24@163.com find $BACKPATH -ctime +30 -name *.sql -delete