diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2020-05-30 14:10:32 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2020-05-30 14:10:32 +0200 |
commit | 66a496a37a16d6a38f8e6334e766a9c8be5f76b7 (patch) | |
tree | 98c1ecbc880d84237def3cd987c6de2aeb5cfe2e | |
parent | c746be70a90c30fa4f84b9a6a6ba1ac24d9d7a81 (diff) | |
download | infrastructure-66a496a37a16d6a38f8e6334e766a9c8be5f76b7.tar.gz infrastructure-66a496a37a16d6a38f8e6334e766a9c8be5f76b7.zip |
WIP consul backup
-rw-r--r-- | docker/bckp/README.md | 11 | ||||
-rw-r--r-- | docker/bckp/kv_to_s3.go | 34 | ||||
-rw-r--r-- | nomad/email.hcl | 4 |
3 files changed, 47 insertions, 2 deletions
diff --git a/docker/bckp/README.md b/docker/bckp/README.md new file mode 100644 index 0000000..4d31bb5 --- /dev/null +++ b/docker/bckp/README.md @@ -0,0 +1,11 @@ +Install dependencies: + +``` +GOBIN=$GOPATH/bin go get . +``` + +Run: + +``` +go run ./kv_to_s3.go +``` diff --git a/docker/bckp/kv_to_s3.go b/docker/bckp/kv_to_s3.go new file mode 100644 index 0000000..76dc0d7 --- /dev/null +++ b/docker/bckp/kv_to_s3.go @@ -0,0 +1,34 @@ +package main +import ( + "github.com/hashicorp/consul/api" + /*"crypto/aes"*/ + "log" + /*"github.com/aws/aws-sdk-go/service/s3"*/ +) + +func errIsPanic(err error, format string, a ...interface{}) { + if err != nil { + log.Panicf(format, a...) + } +} + +func main() { + log.Println("starting consul kv backup...") + conf := api.DefaultConfig() + //@FIXME add later support for a different URL + //@FIXME add later support for HTTPS + + options := api.QueryOptions { + // Prevent from backuping forever silently a desynchronized node + AllowStale: false, + } + + consul, err := api.NewClient(conf) + errIsPanic(err, "Unable to build a new client. %v", err) + + _, _, err = consul.Snapshot().Save(&options) + errIsPanic(err, "Snapshot failed. %v", err) + + + +} diff --git a/nomad/email.hcl b/nomad/email.hcl index 2a70920..75849cd 100644 --- a/nomad/email.hcl +++ b/nomad/email.hcl @@ -74,8 +74,7 @@ job "email" { port = "imap_port" address_mode = "host" tags = [ - "dovecot", - "(diplonat (tcp_port 993))" + "dovecot" ] check { type = "tcp" @@ -96,6 +95,7 @@ job "email" { address_mode = "host" tags = [ "dovecot", + "(diplonat (tcp_port 993))" ] check { |