MySQL备份数据库脚本

时间:2014-04-30 21:41:43   收藏:0   阅读:526
Windows
@echo off
mysqldump --add-drop-database --add-drop-table -u root -p123456 dbname > d:\db_backup\%date:~0,4%-%date:~5,2%-%date:~8,2%_%time:~0,2%-%time:~3,2%-%time:~6,2%_dbname.sql

Linux
#!/bin/sh
cd /usr/bin
DATE=`date +%Y-%m-%d`
# 备份dbname数据库
/usr/local/mysql/bin/mysqldump -uusername -ppassword dbname >/wwwroot/backup/$DATE.sql
cd /wwwroot/backup
#tar -zcvf $DATE.tar.gz $DATE.sql
zip -rP compress_password dbname_$DATE.zip $DATE.sql
rm -f $DATE.sql


来自为知笔记(Wiz)


MySQL备份数据库脚本,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!