- [1].[代码] 压缩备份Mysql数据库 跳至 [1]
- #!/bin/bash
- shijie=`date +%Y%m%d`
- backRenRenDb=renren_minishijie$shijie.sql
- back4399Db=4399_minishijie$shijie.sql
- backManyouDb=Manyou$shijie.sql
- backRenRenFile=renren$shijie.tar.gz
- back4399File=file4399$shijie.tar.gz
- backManyouFile=Manyou$shijie.tar.gz
- password=123456
- cd /var/www/back
- mysqldump -uroot -p$password --default-character-set=utf8 --opt --extended-insert=false --triggers -R --hex-blob --single-transaction renren > $backRenRenDb
- echo -e "Backup "$backRenRenDb" DONE!\n"
- mysqldump -uroot -p$password --default-character-set=utf8 --opt --extended-insert=false --triggers -R --hex-blob --single-transaction 4399 > $back4399Db
- echo -e "Backup "$back4399Db" DOne!\n"
- mysqldump -uroot -p$password --default-character-set=utf8 --opt --extended-insert=false --triggers -R --hex-blob --single-transaction manyou > $backManyouDb
- echo -e "Backup "$backManyouDb" DONE \n";
- tar -zcvf $backRenRenFile $backRenRenDb
- echo -e "Backup File "$backRenRenFile" Done!\n"
- tar -zcvf $back4399File $back4399Db
- echo -e "Back File "$back4399File" Done \n";
- tar -zcvf $backManyouFile $backManyouDb
- echo -e "Back File "$backManyouFile" Done \n";
- rm -f $backManyouDb
- rm -f $backRenRenDb
- rm -f $back4399Db
- echo -e "Backup Done"
- #ftp upload
- ftphost=192.168.1.1
- ftpuser=test
- ftppass=test
- ftp -n $ftphost <<END_SCRIPT
- user $ftpuser $ftppass
- passive
- put $backRenRenFile $backRenRenFile
- bye
- END_SCRIPT
- http://hi.baidu.com/jxvip/blog/item/197e3df3c6a95c5f352accd9.html
时间: 2024-09-21 10:03:08