nexus 数据库备份任务webhook 通知

nexus 的数据库备份是比较重要的,可以方便我们在故障的是时候进行应用恢复。
以下使用benthos 组件进行nexus 数据库备份事件的应用通知处理

环境准备

使用docker-compose 运行

  • docker-compose.yaml 文件
version: "3"
services:
  nexus:
    image: sonatype/nexus3
    ports:
    - "8081:8081"
    volumes:
    - ./nexus-data:/nexus-data
    - ./backup/:/backup/
  benthos:
    image: jeffail/benthos
    volumes:
    - "./webhook.yaml:/benthos.yaml"
    ports:
    - "4195:4195"
  smtp2http:
    image: dalongrong/smtp2http
    command: --listen=:25 --webhook=http://benthos:4195/ --strict=false
  • 启动
docker-compose up -d
  • 说明
    如果出现权限的问题,可以直接设置777 权限,简单(但是不是很合理)chmod 777 backup nexus-data

配置webhook 功能

使用全局webhook

  • 配置全局audit webhook

注意地址使用docker-compose 内置的服务发现功能,实际上就是benthos 服务的信息

  • 配置db exporter 任务
    如下

运行任务&&查看效果

  • 启动任务
    直接点击run运行配置的db exporter 任务
  • 效果
get email message: {"nodeId":"96F7F66A-20527F6B-BB8166EC-C9856291-FEAC65E0","initiator":"*TASK","audit":{"domain":"tasks","type":"started","context":"Admin - Export databases for backup","attributes":{"schedule":"Hourly{properties={schedule.startAt=2019-04-27T16:45:00.000Z, schedule.type=hourly}}","currentState":"CurrentStateImpl{state=RUNNING, nextRun=Sun Apr 28 07:45:00 UTC 2019, future=org.sonatype.nexus.quartz.internal.task.QuartzTaskFuture@74e6c97e}","lastRunState":"LastRunStateImpl{endState=OK, runStarted=Sun Apr 28 06:45:00 UTC 2019, runDuration=545}",".name":"dbbackup","lastRunState.runStarted":"1556433900003",".id":"89fe73e9-0e84-4fdc-8bd1-a29218ca1b50",".typeName":"Admin - Export databases for backup",".visible":"true",".typeId":"db.backup","lastRunState.endState":"OK",".updated":"2019-04-28T06:23:42.575Z",".recoverable":"false",".enabled":"true",".alertEmail":"dalongapp@qq.com",".message":"Admin - Export databases for backup","limitnode":"","lastRunState.runDuration":"545","location":"/backup",".created":"2019-04-28T06:23:42.575Z"}}}
benthos_1 | get email message: {"nodeId":"96F7F66A-20527F6B-BB8166EC-C9856291-FEAC65E0","initiator":"*TASK","audit":{"domain":"tasks","type":"finished","context":"Admin - Export databases for backup","attributes":{"schedule":"Hourly{properties={schedule.startAt=2019-04-27T16:45:00.000Z, schedule.type=hourly}}","currentState":"CurrentStateImpl{state=WAITING, nextRun=Sun Apr 28 07:45:00 UTC 2019, future=null}","lastRunState":"LastRunStateImpl{endState=OK, runStarted=Sun Apr 28 06:56:11 UTC 2019, runDuration=560}",".name":"dbbackup","lastRunState.runStarted":"1556434571288",".id":"89fe73e9-0e84-4fdc-8bd1-a29218ca1b50",".typeName":"Admin - Export databases for backup",".visible":"true",".typeId":"db.backup","lastRunState.endState":"OK",".updated":"2019-04-28T06:23:42.575Z",".recoverable":"false",".enabled":"true",".alertEmail":"dalongapp@qq.com",".message":"Admin - Export databases for backup","limitnode":"","lastRunState.runDuration":"560","location":"/backup",".created":"2019-04-28T06:23:42.575Z"}}}

说明

我们可以用这个功能,使用备份好的数据,以及通知,进行nexus 备份机器的启动还原,方便在故障出现的时候,快速恢复系统,但是有一个要就,就是仓库数据
也同时做了备份,或者使用了共享存储

参考资料

https://github.com/rongfengliang/nexus-webhook-for-dbexporter

posted on   荣锋亮  阅读(985)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2017-04-28 nginx fastcgi 优化
2014-04-28 转 sql 优化
2014-04-28 ORACLE与SQL SERVER语法区别
2014-04-28 oracle 以及 sql server mysql 空值默认值修改
2014-04-28 Oracle C#处理时间类型的Insert

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示