From f733cb21863b2f668a378f67c7512c9cf5be737c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 29 Nov 2019 18:05:46 +0200 Subject: [PATCH] lib/backup: cosmetic fixes after #243 --- app/vmbackup/README.md | 7 ++++--- app/vmrestore/README.md | 6 +++--- lib/backup/actions/util.go | 4 ++-- lib/backup/s3remote/s3.go | 14 ++++++++------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/vmbackup/README.md b/app/vmbackup/README.md index d79cd362c..247fb1acd 100644 --- a/app/vmbackup/README.md +++ b/app/vmbackup/README.md @@ -6,6 +6,7 @@ Supported storage systems for backups: * [GCS](https://cloud.google.com/storage/). Example: `gcs:///` * [S3](https://aws.amazon.com/s3/). Example: `s3:///` +* Any S3-compatible storage such as [MinIO](https://github.com/minio/minio). See `-customS3Endpoint` command-line flag. * Local filesystem. Example: `fs://` Incremental backups and full backups are supported. Incremental backups are created automatically if the destination path already contains data from the previous backup. @@ -129,13 +130,13 @@ Run `vmbackup -help` in order to see all the available options: -configFilePath string Path to file with S3 configs. Configs are loaded from default location if not set. See https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html + -configProfile string + Profile name for S3 configs (default "default") -credsFilePath string Path to file with GCS or S3 credentials. Credentials are loaded from default locations if not set. See https://cloud.google.com/iam/docs/creating-managing-service-account-keys and https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html - -configProfile string - Profile name for S3 configs. (default "default") -customS3Endpoint string - Custom S3 endpoint for use with S3-compatible storages (e.g. MinIO) + Custom S3 endpoint for use with S3-compatible storages (e.g. MinIO). S3 is used if not set -dst string Where to put the backup on the remote storage. Example: gcs://bucket/path/to/backup/dir, s3://bucket/path/to/backup/dir or fs:///path/to/local/backup/dir -dst can point to the previous backup. In this case incremental backup is performed, i.e. only changed data is uploaded diff --git a/app/vmrestore/README.md b/app/vmrestore/README.md index b16a1b4ca..1e62d143c 100644 --- a/app/vmrestore/README.md +++ b/app/vmrestore/README.md @@ -40,13 +40,13 @@ Run `vmrestore -help` in order to see all the available options: -configFilePath string Path to file with S3 configs. Configs are loaded from default location if not set. See https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html + -configProfile string + Profile name for S3 configs (default "default") -credsFilePath string Path to file with GCS or S3 credentials. Credentials are loaded from default locations if not set. See https://cloud.google.com/iam/docs/creating-managing-service-account-keys and https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html - -configProfile string - Profile name for S3 configs. (default "default") -customS3Endpoint string - Custom S3 endpoint for use with S3-compatible storages (e.g. MinIO) + Custom S3 endpoint for use with S3-compatible storages (e.g. MinIO). S3 is used if not set -loggerLevel string Minimum level of errors to log. Possible values: INFO, ERROR, FATAL, PANIC (default "INFO") -maxBytesPerSecond int diff --git a/lib/backup/actions/util.go b/lib/backup/actions/util.go index 064c657c0..ffc7097c3 100644 --- a/lib/backup/actions/util.go +++ b/lib/backup/actions/util.go @@ -18,8 +18,8 @@ var ( "See https://cloud.google.com/iam/docs/creating-managing-service-account-keys and https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html") configFilePath = flag.String("configFilePath", "", "Path to file with S3 configs. Configs are loaded from default location if not set.\n"+ "See https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html") - configProfile = flag.String("configProfile", "default", "Profile name for S3 configs. ") - customS3Endpoint = flag.String("customS3Endpoint", "", "Custom S3 endpoint for use with S3-compatible storages (e.g. MinIO)") + configProfile = flag.String("configProfile", "default", "Profile name for S3 configs") + customS3Endpoint = flag.String("customS3Endpoint", "", "Custom S3 endpoint for use with S3-compatible storages (e.g. MinIO). S3 is used if not set") ) func runParallel(concurrency int, parts []common.Part, f func(p common.Part) error, progress func(elapsed time.Duration)) error { diff --git a/lib/backup/s3remote/s3.go b/lib/backup/s3remote/s3.go index c69295c38..48a1d0d17 100644 --- a/lib/backup/s3remote/s3.go +++ b/lib/backup/s3remote/s3.go @@ -21,7 +21,7 @@ type FS struct { // Path to S3 credentials file. CredsFilePath string - // Pat to S3 configs file. + // Path to S3 configs file. ConfigFilePath string // GCS bucket to use. @@ -30,10 +30,14 @@ type FS struct { // Directory in the bucket to write to. Dir string - s3 *s3.S3 - uploader *s3manager.Uploader + // Set for using S3-compatible enpoint such as MinIO etc. CustomEndpoint string - ProfileName string + + // The name of S3 config profile to use. + ProfileName string + + s3 *s3.S3 + uploader *s3manager.Uploader } // Init initializes fs. @@ -63,7 +67,6 @@ func (fs *FS) Init() error { } if len(fs.CustomEndpoint) > 0 { - // Use provided custom endpoint for S3 logger.Infof("Using provided custom S3 endpoint: %q", fs.CustomEndpoint) sess.Config.WithEndpoint(fs.CustomEndpoint) @@ -71,7 +74,6 @@ func (fs *FS) Init() error { // Disable prefixing endpoint with bucket name sess.Config.WithS3ForcePathStyle(true) } else { - // Determine bucket region. ctx := context.Background() region, err := s3manager.GetBucketRegion(ctx, sess, fs.Bucket, "")