mysql 文件夹 备份

backup.sh
[quote]#!/bin/sh
USER=root
PASSWORD=admin
DATABASE=cms
WEBMASTER=XX@qq.com
CMS_DIR=/usr/apache-tomcat/webapps/cms
BACKUP_DIR=/var/wtcsg/Data_Backup/mysql/
BACKUP_DIR_TOMCAT=/var/wtcsg/Data_Backup/tomcat/

LOGFILE=/var/wtcsg/Data_Backup/mysql/data_backup.log
#DATE=date +%Y%m%d-%H%M
DATE=$(date +%Y%m%d)
DUMPFILE=DATE
OPTIONS=" [color=red]--opt --host=127.0.0.1 -u$USER -p$PASSWORD -R --triggers --single-transaction --flush-logs --database $DATABASE[/color] "

if [ ! -d $BACKUP_DIR ] ;
then
mkdir -p "$BACKUP_DIR"
fi
if [ ! -d $BACKUP_DIR_TOMCAT ][ $? == 0 ]; then


echo "[$ARCHIVE] Backup_mysql Successful!" >> $LOGFILE

fi
echo " " >> $LOGFILE
echo " " >> $LOGFILE
echo "----------------" >> $LOGFILE
echo "BACKUP_TOMCAT DATE:" $(date +"%y-%m-%d %H:%M:%S") >> $LOGFILE
echo "---------------- " >> $LOGFILE
#cp -rf /usr/apache-tomcat/webapps/cms $BACKUP_DIR_TOMCAT
cd $BACKUP_DIR_TOMCAT
[color=red]tar -czf cms$(date +%F).tar.gz $CMS_DIR[/color]

#cd /usr/apache-tomcat/webapps/cms
#tar -czf BACKUP_DIR_TOMCATcms$(date +%F).tar.gz $CMS_DIR





echo "[$ARCHIVE] Backup_tomcat Successful!" >> $LOGFILE

echo "Backup Process Done"[/quote]
--------------------------

chmod +x backup.sh   //授权


--------------------------
vi /etc/crontab    // 定时服务


# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly


--------------------------
service crond restart

----------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值