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
评论(0)