68218866 发表于 2011-12-6 09:37:44

军哥您帮忙看看这样写对吗?

# vi mysql-backup.sh
db_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点执行

licess 发表于 2011-12-6 09:53:49

页: [1]
查看完整版本: 军哥您帮忙看看这样写对吗?