ubuntu 上shell脚本实现数据库的定时备份和删除一个月以前的数据
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 =====================
- 相关文章
- 查看评论:(0)
【已经有0位大神发现了看法】
- 光线多播放器功能出炉了 2012-09-02
- 光线CMS(gxcms)多播放器支持以及一键采集 2012-08-28
- [原创]光线cms(gxcms)支持迅雷下载链接的修改 2012-08-25
- [原创]光线CMS(gxcms)下载远程图片插件说明 2012-05-08
- [原创]光线CMS(gxcms)采集伪原创内容插件说明(2013-09-10更新) 2012-05-06
- [分享]数据调用说明,光线CMS标签 2012-04-16
- [分享]专题模块变量及循环标签,光线CMS标签 2012-04-16
- [分享]视频模块变量及循环标签,光线CMS标签 2012-04-16
- [分享]幻灯循环标签,光线CMS标签 2012-04-16
- [分享]条件判断标签说明,光线CMS标签 2012-04-16
发表评论: