add monitoring to backup
This commit is contained in:
parent
ce9ad5d077
commit
8973267393
6 changed files with 30 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -27,3 +27,4 @@ public/js/
|
|||
|
||||
.eastwood
|
||||
|
||||
.envrc
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM domaindrivenarchitecture/dda-backup:5.3.0
|
||||
FROM domaindrivenarchitecture/dda-backup:5.4.0
|
||||
|
||||
ADD resources /tmp
|
||||
RUN /tmp/install.bb
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
'[dda.backup.config :as cfg]
|
||||
'[dda.backup.restic :as rc]
|
||||
'[dda.backup.postgresql :as pg]
|
||||
'[dda.backup.monitoring :as mon]
|
||||
'[dda.backup.backup :as bak])
|
||||
|
||||
(def config (cfg/read-config "/usr/local/bin/config.edn"))
|
||||
|
@ -24,6 +25,13 @@
|
|||
(bak/backup-file! (:file-config config))
|
||||
(bak/backup-db! (:db-config config)))
|
||||
|
||||
(prepare!)
|
||||
(restic-repo-init!)
|
||||
(restic-backup!)
|
||||
|
||||
(try
|
||||
(restic-repo-init!)
|
||||
(mon/backup-start-metrics! (:db-config config))
|
||||
(prepare!)
|
||||
(restic-repo-init!)
|
||||
(restic-backup!)
|
||||
(mon/backup-success-metrics! (:db-config config))
|
||||
(catch Exception e
|
||||
(mon/backup-fail-metrics! (:db-config config))))
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{:restic-repo {:password-file #env-or-file "RESTIC_PASSWORD_FILE"
|
||||
:restic-repository #env-or-file "RESTIC_REPOSITORY"}
|
||||
{:monitoring {:namespace "forgejo"}
|
||||
|
||||
:restic-repo #merge [#ref [:monitoring]
|
||||
{:password-file #env-or-file "RESTIC_PASSWORD_FILE"
|
||||
:restic-repository #env-or-file "RESTIC_REPOSITORY"}]
|
||||
|
||||
:file-config #merge [#ref [:restic-repo]
|
||||
{:backup-path "files"
|
||||
:execution-directory "/var/backups/"
|
||||
:files ["gitea/" "git/repositories/"]}]
|
||||
|
||||
|
||||
:db-config #merge [#ref [:restic-repo]
|
||||
{:backup-path "pg-database"
|
||||
:pg-host #env-or-file "POSTGRES_SERVICE"
|
||||
|
|
|
@ -14,4 +14,5 @@
|
|||
(in/install! "list-snapshots.bb")
|
||||
(in/install! "change-password.bb")
|
||||
(in/install! "wait.bb")
|
||||
(in/install! "monitoring.bb")
|
||||
(ub/cleanup-container!)
|
11
infrastructure/backup/image/resources/monitoring.bb
Normal file
11
infrastructure/backup/image/resources/monitoring.bb
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bb
|
||||
|
||||
(require
|
||||
'[dda.backup.monitoring :as mon])
|
||||
|
||||
(def config {:metrics {:kube_job_status_active 0
|
||||
:kube_job_status_failed 1
|
||||
:kube_job_status_succeeded 0
|
||||
:kube_job_status_start_time (/ (System/currentTimeMillis) 1000)}})
|
||||
|
||||
(mon/send-metrics! config)
|
Loading…
Add table
Reference in a new issue