简单的备份mysql中的数据库,并上传到ftp服务器上
[root@zhu2 ~]# vim mysql_backup.sh#!/usr/bin/bashUSERNAME=rootPASSWORD=123456DATE=`date +%F`OLDDATE=`date +%F -d '-20 days'`FTPOLDDATE=`date +%F -d '-30 days'`MYSQL=/opt/mysql/bin/mysqlMYSQLDUMP=/opt/mysql/bin/mysqldumpBACKDIR=/data_backup[ -d ${BACKDIR} ] || mkdir -p ${BACKDIR}[ -d ${BACKDIR}/${DATE} ] || mkdir ${BACKDIR}/${DATE}[ ! -d ${BACKDIR}/${OLDDATE} ] || rm -rf ${BACKDIR}/${OLDDATE}for DBNAME in mysql zabbix zhujiangtaodoecho "${DBNAME} has been backup successfully"doneFTP_SERVER=192.168.70.137FTP_USER=zabbixFTP_PASSWORD=zabbixcd ${BACKDIR}/${DATE}/usr/bin/ftp -i -n -v <