Centos上通过shell脚本备份数据库
#!/bin/bash ds=`date +%s%N|cut -c1-13` list=`date +%Y`/`date +%m` dname="callme" eval "mkdir -p $list" ls_date=`date +%Y%m%d` echo ${ls_date} bk="mysqldump -R -E -h 127.0.0.1 -uroot -ppass ${dname} --result-file=${list}/${dname}-${ls_date}.sql" echo $bk eval $bk cd $list tar -czf callme-${ls_date}.tar.gz *.sql rm -rf *.sql cd ../.. mkdir -p logs/$list cd logs/$list de=`date +%s%N|cut -c1-13` echo -e "`date +%Y%m%d%H%M%S` 数据备份成功" >> ${dname}.${ls_date}.log echo -e "Running time:: $((${de}-${ds}))" >> ${dname}.${ls_date}.log echo -e "Running time:: $((${de}-${ds}))"