军哥您帮忙看看这样写对吗?
# vi mysql-backup.shdb_user="root"
db_passwd="123456"
db_host="192.168.1.110"
db_name="ecshop"
# the directory for story your backup file.
backup_dir="/backup"
# date format for backup file (dd-mm-yyyy)
time="$(date +"%Y-%m-%d-%H-%M-%S")"
# mysql, mysqldump and some other bin's path
MYSQL="/usr/local/mysql/bin/mysql"
MYSQLDUMP="/usr/local/mysql/bin/mysqldump"
GZIP="/bin/gzip"
$MYSQLDUMP -u $db_user -h $db_host -p$db_passwd $db_name | $GZIP -9 > "$backup_dir/$db_name"_"$time.gz"
让备份脚本每天自动执行
# crontab –e
# 00 03 * * * /mysql-backup.sh // 每天凌晨3点执行 对
页:
[1]