aboutsummaryrefslogtreecommitdiff
path: root/docker/bckp/kv_to_s3.go
diff options
context:
space:
mode:
Diffstat (limited to 'docker/bckp/kv_to_s3.go')
-rw-r--r--docker/bckp/kv_to_s3.go34
1 files changed, 34 insertions, 0 deletions
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)
+
+
+
+}