Home > Database > Mysql Tutorial > mysql的自动备份_MySQL

mysql的自动备份_MySQL

WBOY
Release: 2016-06-01 13:55:34
Original
980 people have browsed it

time=`date  +%G%I%d%H%M` #年月日时分

db=products
echo "#产品库" >/sqlbak/${db}_$time.sql  #备份文件名为[库名_年月日时分.sql]
mysqldump --add-drop-table -c  --allow-keywords --force --password=1234567890 --user=root $db >>/sqlbak/${db}_$time.sql

db=news   #另一个库

echo "#新闻库" >/sqlbak/${db}_$time.sql
mysqldump --add-drop-table -c  --allow-keywords --force --password=1234567890 --user=root $db |bzip2 -9 >/sqlbak/${db}_$time.sql.bz2

#--add-drop-table是添加一个删出命令。
#-c是完整插入,每行插入都包括字段名
#--force是出错也继续
#--allow-keywords是对于保留字做字段名时对字段名加反引号。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template