mysql中通过shell脚本备份数据库
脚本如下(已测试通过):
#! /bin/bash
echo "backup mysql"
###date stamp###
datestamp=$(date +%Y-%m-%d)
echo $datestamp
###path###
startdir=/home/ck/mysqlbak
###bakfile prefix###
fileprefix=sql
echo "sqldump is starting"
mysqldump -u root -p -l ck1 > $startdir/$fileprefix$datestamp.sql
echo "sqldump is done"