shell脚本实现mysql数据备份与清理
SCRIPT
curdate=`date +%Y-%m-%d_%H-%M` backupdir=”/opt/backup/db” databasename=”DBName” username=”root” password=”–skip-password” # if password isn’t empty use “-pxxxxx” #the number of days to keep backups keepbackups=`date -d ’30 days ago’ +%Y-%m-%d` echo ===================== echo Start backup MySQL DB mysqldump -u${username} ${password} ${databasename} > ${backupdir}/${databasename}_${curdate}.sql echo Done. echo Deleting old backups cd $backupdir find . -name “${databasename}_${keepbackups}*” | xargs rm -rf echo Done. echo =====================
相关推荐
laisean 2020-11-11
Julyth 2020-10-16
laisean 2020-09-27
flycappuccino 2020-09-27
liguojia 2020-09-27
tufeiax 2020-09-03
huha 2020-10-16
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
以梦为马不负韶华 2020-10-20
JohnYork 2020-10-16
applecarelte 2020-10-16
wangzhaotongalex 2020-09-22
流年浅滩 2020-10-23
liujianhua 2020-10-22
woaimeinuo 2020-10-21
laisean 2020-09-01
vvu 2020-09-16
libao 2020-09-16
Yyqingmofeige 2020-08-18
zhushixia 2020-08-17