forked from Deuxfleurs/infrastructure
WIP consul backup
This commit is contained in:
parent
c746be70a9
commit
66a496a37a
3 changed files with 47 additions and 2 deletions
11
docker/bckp/README.md
Normal file
11
docker/bckp/README.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Install dependencies:
|
||||||
|
|
||||||
|
```
|
||||||
|
GOBIN=$GOPATH/bin go get .
|
||||||
|
```
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```
|
||||||
|
go run ./kv_to_s3.go
|
||||||
|
```
|
34
docker/bckp/kv_to_s3.go
Normal file
34
docker/bckp/kv_to_s3.go
Normal file
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -74,8 +74,7 @@ job "email" {
|
||||||
port = "imap_port"
|
port = "imap_port"
|
||||||
address_mode = "host"
|
address_mode = "host"
|
||||||
tags = [
|
tags = [
|
||||||
"dovecot",
|
"dovecot"
|
||||||
"(diplonat (tcp_port 993))"
|
|
||||||
]
|
]
|
||||||
check {
|
check {
|
||||||
type = "tcp"
|
type = "tcp"
|
||||||
|
@ -96,6 +95,7 @@ job "email" {
|
||||||
address_mode = "host"
|
address_mode = "host"
|
||||||
tags = [
|
tags = [
|
||||||
"dovecot",
|
"dovecot",
|
||||||
|
"(diplonat (tcp_port 993))"
|
||||||
]
|
]
|
||||||
|
|
||||||
check {
|
check {
|
||||||
|
|
Loading…
Reference in a new issue