大旗谷资源网 Design By www.zqyou.com
下面先给大家介绍tomcat应用文件备份脚本
#!/bin/bash #Back up the entire tomcat8080-dist to the /backup directory backuppath=/mnt/tomcat8080-dist/webapps/ backpath=/backup/backup-tomcat8080-dist/ action=/backup/backup-tomcat8080-dist/ APPNAME=dist BACKUPNAME1=dist BACKUPNAME2=spongod-module-admin BACKUPNAME3=spongod-module-interface for i in 1,2,3 do echo "" /backup/log/backup.log done echo "this backup start!" /backup/log/backup.log #echo "----STRAT BACKUP TIME:`date '+%Y%m%d-%H%M'`" /backup/log//backup.log if [[ -n $backpath ]] && [[ -n $backuppath ]];then echo "--------STARTUP BACKUP TIME:`date '+%Y-%m-%d-%H-%M'`-------" /backup/log/backup.log cd /mnt/tomcat8080-dist/ 2 /backup/log/backup.log time=`date '+%Y-%m-%d-%H-%M'` tar czf /backup/backup-tomcat8080-dist/$APPNAME-$time\.tar.gz webapps/$BACKUPNAME1/ webapps/$BACKUPNAME2/ webapps/$BACKUPNAME3/ 2/backup/log/BackupFailed.log if [ $"----\033[32m BACKUP SUCCESSFUL\033[0m-----------------------" /backup/log/backup.log echo "--------BACKUP END TIME is:`date '+%Y-%m-%d-%H-%M'`--------" /backup/log/backup.log echo "This backup ends" /backup/log/backup.log for i in 1,2,3 do echo "" /backup/log/backup.log done else echo -e "----\033[31m Backup failed, please try again \033[0m -------------" /backup/log/BackupFailed.log echo "--------Failed Time:`date '+%Y-%m-%d-%H-%M'`-----------" /backup/log/BackupFailed.log fi fi #Delete files from three days away echo "" /backup/log/delete-backup.log echo "start deleted file" /backup/log/delete-backup.log find $action -mtime +3 -type f |xargs rm -f if [ $"----------File deleted successfully--------------" /backup/log/delete-backup.log else echo "----------File deletion failed-------------------" /backup/log/delete-backup.log echo "" /backup/log/delete-backup.log fi
下面给大家介绍tomcat的日志备份脚本
这个是python脚本,默认对tomcat日志保存15天,我们自己可以手动修改的
#!/usr/bin/env python #-*- coding:utf-8 -*- import os,datetime,shutil,time logRootPath = "/data/webservers" backupRootPath = "/data/logs/backup/tomcat" delNDayBefore = 15 def getYestoday(): now = datetime.datetime.now() delta = datetime.timedelta(days=-1) yestoday = now + delta yestodayStr = yestoday.strftime('%Y%m%d') return yestodayStr def createDir(path): if not os.path.exists(path): os.makedirs(path) def backupLog(): for path in os.listdir(logRootPath): logPath = os.path.join(os.path.join(logRootPath, path), "logs") backupPath = os.path.join(backupRootPath, path) logFilePath = os.path.join(logPath, "catalina.out") targetFileName = "catalina.out." + getYestoday() targetFilePath = os.path.join(backupPath, targetFileName) createDir(backupPath) shutil.copy(logFilePath,targetFilePath) os.system("echo '' > %s" % (logFilePath)) def getNDayTime(n): currTime = time.time() deltTime = 3600*24*n # n天前 return currTime - deltTime def delLog(): fileInfos = os.walk(backupRootPath) beforeTime = getNDayTime(delNDayBefore) for path,d,filelist in fileInfos: for filename in filelist: filePath = os.path.join(path, filename) modifyTime = os.stat(filePath).st_mtime print(filePath,":",modifyTime,"-",beforeTime,"-",modifyTime < beforeTime) if modifyTime < beforeTime: print("remove file %s" % (filePath)) os.remove(filePath) def do(): backupLog() delLog() if __name__ == "__main__": do()
总结
以上所述是小编给大家介绍的tomcat应用文件备份脚本及日志备份脚本的示例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
大旗谷资源网 Design By www.zqyou.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
大旗谷资源网 Design By www.zqyou.com
暂无tomcat应用文件备份脚本及日志备份脚本的示例代码的评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2024年11月14日
2024年11月14日
- 姚璎格《 粤 24KGOLD》正版低速原抓[WAV+CUE][1G]
- 杨千嬅《如果大家都拥有海》寰亚 [WAV+CUE][998M]
- 孟庭苇.1994-1990-1994钻石精选集2CD(2022环球XRCD限量版)【上华】【WAV+CUE】
- 群星.1998-华纳好情歌精选17首【华纳】【WAV+CUE】
- 张敬轩王菀之.2006-903.ID.CLUB拉阔演奏厅LIVE.2CD【环球】【WAV+CUE】
- 《欢欣森活》存档方法
- 《炉石传说》2024新赛季上线更新内容问题汇总
- 《南瓜恐慌》进不去游戏解决方法
- 杨烁《杨烁唱唐诗》2024Hi-Res[WAV分轨]
- 杨烁《杨烁唱唐诗》2024Hi-Res[WAV分轨]
- 童丽《民歌童丽(HQCD)》【WAV+CUE】
- 童丽《绝对收藏》2022头版限量编号[WAV+CUE][1G]
- 腾格尔《出走天堂》MQA-UHQCD限量版[低速原抓WAV+CUE][1G]
- 田震《时光音乐会》纯银CD[低速原抓WAV+CUE][1G]
- 炉石传说11月初最强登顶卡组合集 炉石传说11月初登顶卡组分享