From 3c112d9cae96e11d1fb141312bafa8d52c7e9a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Tue, 26 Mar 2019 16:37:07 +0100 Subject: [PATCH] s3: Add config option to set storage class The `s3.storage-class` option can be passed to restic (using `-o`) to specify the storage class to be used for S3 objects created by restic. The storage class is passed as-is to S3, so it needs to be understood by the API. On AWS, it can be one of `STANDARD`, `STANDARD_IA`, `ONEZONE_IA`, `INTELLIGENT_TIERING` and `REDUCED_REDUNDANCY`. If unspecified, the default storage class is used (`STANDARD` on AWS). You can mix storage classes in the same bucket, and the setting isn't stored in the restic repository, so be sure to specify it with each command that writes to S3. Closes #706 --- internal/backend/s3/config.go | 1 + internal/backend/s3/s3.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/backend/s3/config.go b/internal/backend/s3/config.go index 1760f48c2..932806714 100644 --- a/internal/backend/s3/config.go +++ b/internal/backend/s3/config.go @@ -18,6 +18,7 @@ type Config struct { Bucket string Prefix string Layout string `option:"layout" help:"use this backend layout (default: auto-detect)"` + StorageClass string `option:"storage-class" help:"set S3 storage class (STANDARD, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING or REDUCED_REDUNDANCY)"` 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"` diff --git a/internal/backend/s3/s3.go b/internal/backend/s3/s3.go index 70a052868..e3c95001d 100644 --- a/internal/backend/s3/s3.go +++ b/internal/backend/s3/s3.go @@ -260,7 +260,7 @@ func (be *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindRe be.sem.GetToken() defer be.sem.ReleaseToken() - opts := minio.PutObjectOptions{} + opts := minio.PutObjectOptions{StorageClass: be.cfg.StorageClass} opts.ContentType = "application/octet-stream" debug.Log("PutObject(%v, %v, %v)", be.cfg.Bucket, objName, rd.Length())