shell定时备份数据库信息

#!/bin/sh

# Database info
DB_USER="batsing"
DB_PASS="batsingpw"
DB_HOST="localhost"
DB_NAME="timepusher"

# Others vars
BIN_DIR="/usr/bin"            #the mysql bin path
BCK_DIR="/mnt/mysqlBackup"    #the backup file directory
DATE=`date +%F`

# TODO
# /usr/bin/mysqldump --opt -ubatsing -pbatsingpw -hlocalhost timepusher > /mnt/mysqlBackup/db_`date +%F`.sql
$BIN_DIR/mysqldump --opt -u$DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME > $BCK_DIR/db_$DATE.sql

#还原数据库
#用mysql-front导入前一天的 *.sql 文件即可恢复数据
原文地址:https://www.cnblogs.com/go4mi/p/5764190.html