Skip to content

Commit

Permalink
feat: Add storage class header (#119)
Browse files Browse the repository at this point in the history
* feat: Add storage class header

* doc: change the readme

* chore: Remove the unnecessary default  value
  • Loading branch information
erwanlpfr committed Jul 6, 2022
1 parent e738bd0 commit 3661a4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ You can populate below template according to your requirements and use it as you

# AWS_ENDPOINT_INSECURE="true"

# Setting this variable will change the S3 storage class header.
# Defaults to "STANDARD", you can set this value according to your needs.

# AWS_STORAGE_CLASS="GLACIER"

# You can also backup files to any WebDAV server:

# The URL of the remote WebDAV server
Expand Down
1 change: 1 addition & 0 deletions cmd/backup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Config struct {
AwsEndpoint string `split_words:"true" default:"s3.amazonaws.com"`
AwsEndpointProto string `split_words:"true" default:"https"`
AwsEndpointInsecure bool `split_words:"true"`
AwsStorageClass string `split_words:"true"`
AwsAccessKeyID string `envconfig:"AWS_ACCESS_KEY_ID"`
AwsSecretAccessKey string `split_words:"true"`
AwsIamRoleEndpoint string `split_words:"true"`
Expand Down
8 changes: 5 additions & 3 deletions cmd/backup/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"context"
"errors"
"fmt"
"github.com/pkg/sftp"
"golang.org/x/crypto/ssh"
"io"
"io/fs"
"io/ioutil"
Expand All @@ -20,6 +18,9 @@ import (
"text/template"
"time"

"github.com/pkg/sftp"
"golang.org/x/crypto/ssh"

"github.com/containrrr/shoutrrr"
"github.com/containrrr/shoutrrr/pkg/router"
"github.com/docker/docker/api/types"
Expand Down Expand Up @@ -547,7 +548,8 @@ func (s *script) copyBackup() error {

if s.minioClient != nil {
if _, err := s.minioClient.FPutObject(context.Background(), s.c.AwsS3BucketName, filepath.Join(s.c.AwsS3Path, name), s.file, minio.PutObjectOptions{
ContentType: "application/tar+gzip",
ContentType: "application/tar+gzip",
StorageClass: s.c.AwsStorageClass,
}); err != nil {
return fmt.Errorf("copyBackup: error uploading backup to remote storage: %w", err)
}
Expand Down

0 comments on commit 3661a4b

Please sign in to comment.