sip=xxx.xxx.xxx.xxx user=user passwd=passwd back_path=/home/xxxxx/mysqlbak data_name=data_name date=`date +%Y%m%d` mkdir $back_path/$date mysqldump -h $sip -u$user -p$passwd $data_name |gzip > $back_path/$date/$data_name.sql.gz
创建定时任务
crontab -e
00 01 * * * /usr/local/scripts/xxx/mysql_bak.sh
每天凌晨1点执行