鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 服务器相关 > 批处理 > >

备份压缩mysql 数据库

来源:互联网 作者:佚名 时间:2016-03-03 12:15
适用于Linux平台下的一个定时备份压缩数据库代码 备份 MySQL #!/bin/bashshijie=`date +%Y%m%d`backRenRenDb=renren_minishijie$shijie.sqlback4399Db=4399_minishijie$shijie.sqlbackManyouDb=Manyou$shijie.sqlbackRenRenFile=renren$shijie.tar.gzback4399
适用于Linux平台下的一个定时备份压缩数据库代码
备份 MySQL
#!/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
网友评论
<