From cf65893c4b3ad7bd6b834c045aa8869be42f4135 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 12 Jun 2017 21:09:26 +0200 Subject: [PATCH] s3: Allow setting the number of retries for minio-go https://github.com/restic/restic/issues/1013#issuecomment-307883970 --- src/restic/backend/s3/config.go | 1 + src/restic/backend/s3/s3.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/restic/backend/s3/config.go b/src/restic/backend/s3/config.go index 45a040d86..673b1aaad 100644 --- a/src/restic/backend/s3/config.go +++ b/src/restic/backend/s3/config.go @@ -20,6 +20,7 @@ type Config struct { Layout string `option:"layout" help:"use this backend layout (default: auto-detect)"` Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"` + MaxRetries uint `option:"retries" help:"set the number of retries attempted"` } // NewConfig returns a new Config with the default values filled in. diff --git a/src/restic/backend/s3/s3.go b/src/restic/backend/s3/s3.go index aa557e7e4..6550d1912 100644 --- a/src/restic/backend/s3/s3.go +++ b/src/restic/backend/s3/s3.go @@ -37,6 +37,10 @@ const defaultLayout = "default" func Open(cfg Config) (restic.Backend, error) { debug.Log("open, config %#v", cfg) + if cfg.MaxRetries > 0 { + minio.MaxRetry = int(cfg.MaxRetries) + } + client, err := minio.New(cfg.Endpoint, cfg.KeyID, cfg.Secret, !cfg.UseHTTP) if err != nil { return nil, errors.Wrap(err, "minio.New")