(Tomcat) 部署时备份 WAR [英] (Tomcat) Backup WAR on Deploy

查看:30
本文介绍了(Tomcat) 部署时备份 WAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何内置机制来备份部署在 Tomcat 中的 war 文件?

Are there any built in mechanisms to backup a war file on deploy in Tomcat?

例如,我部署 whosit.war.我想要当前部署的 whosit.war 备份到 whosit-backup.war.或者,如果每个部署都在 whosit-deploy-20110317-211037.war 中保留了一份额外的部署副本.等等等等

For example, I deploy whosit.war. I want the current whosit.war that's deployed to backup to whosit-backup.war. Or if each deploy kept an extra copy of the deploy at whosit-deploy-20110317-211037.war. etc etc.

显然我可以将它添加到我的部署脚本中,但如果 Tomcat 执行上述任何操作,它会让我的生活变得如此美好.

Obviously I could add this to my deploy script but it would make my life so nice if Tomcat did anything like the above.

推荐答案

您可以通过指定 tag 属性在远程部署 Web 应用程序时标记部署.如果您使用 Maven,您可以 使用 tomcat-plugin 指定标签.假设您已经有了插件设置,您只需要指定属性.示例:

You can tag a deploy when deploying a webapp remotely by specifying the tag attribute. If you're using Maven you can specify the tag with the tomcat-plugin. Assuming you already have the plugin setup you need only to specify the property. Example:

<properties>
    <maven.tomcat.url>http://example.com:8080/manager</maven.tomcat.url>
    <tomcat.username>tomcat</tomcat.username>
    <tomcat.password>tomcat</tomcat.password>
    <maven.tomcat.tag>mytag</maven.tomcat.tag>
    <maven.tomcat.path>/myapp</maven.tomcat.path>
</properties>

这将在您的经理的工作目录中以您的标签命名的目录中创建战争的副本(例如 $CATALINA_HOME/work/Catalina/localhost/manager/mytag).您可以通过指定 pathtag 来通过管理器检索和重新部署此战争:

This will create a copy of the war in the work directory of your manager in a directory named after your tag (e.g. $CATALINA_HOME/work/Catalina/localhost/manager/mytag). You can retrieve and redeploy this war through the manager by specifying the path and tag:

http://example.com:8080/manager/deploy?path=/myapp&tag=mytag

注意:如果管理器工作目录被删除,那么您的标记部署将消失.

Note: if the manager work directory ever gets deleted then your tagged deploys will be gone.

这篇关于(Tomcat) 部署时备份 WAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆