备份 项目 mysql linux shell
#!/bin/sh
echo"backup517playandmysql"
BACKUP_DIR=/var/www/Data_Backup/
DATE=`date'+%Y%m%d-%H%M'`
SOURCE=/root/aaa.log
TEMP517PLAY=517play
DISK517PLAY=${TEMP517PLAY}_$DATE.tar.gz
SQLNAME=${TEMP517PLAY}_sql_$DATE.tar.gz
if[!-d$BACKUP_DIR];
then
mkdir-p"$BACKUP_DIR"
fi
scp-r$SOURCE$BACKUP_DIR/$TEMP517PLAY
if[$?==0];then
cd$BACKUP_DIR
tarzcvf$DISK517PLAY$TEMP517PLAY
echo"backupsuccessful"
rm -rf $TEMP517PLAY#"backupmysql"
USER=root
PASSWORD=root
DATABASE=mysql
mysqldump--default-character-set=utf8-u$USER-p$PASSWORD$DATABASE>$TEMP517PLAY.sql
echo"mysqlbackupsuccess!"
tarzcvf$SQLNAME$TEMP517PLAY.sql
rm -fr $TEMP517PLAY.sql#remove7daysfile
find-ctime+7-name"$TEMP517PLAY*"|xargsrm-rf
else
echo"backupfail"
fi
相关推荐
tianhuak 2020-11-24
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
farwang 2020-11-25
星愿心愿 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20