Merge pull request #2484 from restic/add-s3-region
s3: Allow specifying region
This commit is contained in:
commit
e14c4b1737
5 changed files with 21 additions and 7 deletions
8
changelog/unreleased/pull-2350
Normal file
8
changelog/unreleased/pull-2350
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Enhancement: Add option to configure S3 region
|
||||||
|
|
||||||
|
We've added a new option for setting the region when accessing an S3-compatible
|
||||||
|
service. For some providers, it is required to set this to a valid value. You
|
||||||
|
can do that either by setting the environment variable `AWS_DEFAULT_REGION` or
|
||||||
|
using the option `s3.region`, e.g. like this: `-o s3.region="us-east-1"`.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/2350
|
|
@ -485,6 +485,10 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
|
||||||
cfg.Secret = os.Getenv("AWS_SECRET_ACCESS_KEY")
|
cfg.Secret = os.Getenv("AWS_SECRET_ACCESS_KEY")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.Region == "" {
|
||||||
|
cfg.Region = os.Getenv("AWS_DEFAULT_REGION")
|
||||||
|
}
|
||||||
|
|
||||||
if err := opts.Apply(loc.Scheme, &cfg); err != nil {
|
if err := opts.Apply(loc.Scheme, &cfg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,10 +197,11 @@ default location:
|
||||||
Please note that knowledge of your password is required to access the repository.
|
Please note that knowledge of your password is required to access the repository.
|
||||||
Losing your password means that your data is irrecoverably lost.
|
Losing your password means that your data is irrecoverably lost.
|
||||||
|
|
||||||
It is not possible at the moment to have restic create a new bucket in a
|
If needed, you can manually specify the region to use by either setting the
|
||||||
different location, so you need to create it using a different program.
|
environment variable ``AWS_DEFAULT_REGION`` or calling restic with an option
|
||||||
Afterwards, the S3 server (``s3.amazonaws.com``) will redirect restic to
|
parameter like ``-o s3.region="us-east-1"``. If the region is not specified,
|
||||||
the correct endpoint.
|
the default region is used. Afterwards, the S3 server (at least for AWS,
|
||||||
|
``s3.amazonaws.com``) will redirect restic to the correct endpoint.
|
||||||
|
|
||||||
Until version 0.8.0, restic used a default prefix of ``restic``, so the files
|
Until version 0.8.0, restic used a default prefix of ``restic``, so the files
|
||||||
in the bucket were placed in a directory named ``restic``. If you want to
|
in the bucket were placed in a directory named ``restic``. If you want to
|
||||||
|
|
|
@ -20,8 +20,9 @@ type Config struct {
|
||||||
Layout string `option:"layout" help:"use this backend layout (default: auto-detect)"`
|
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)"`
|
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)"`
|
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"`
|
MaxRetries uint `option:"retries" help:"set the number of retries attempted"`
|
||||||
|
Region string `option:"region" help:"set region"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfig returns a new Config with the default values filled in.
|
// NewConfig returns a new Config with the default values filled in.
|
||||||
|
|
|
@ -66,7 +66,7 @@ func open(cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
client, err := minio.NewWithCredentials(cfg.Endpoint, creds, !cfg.UseHTTP, "")
|
client, err := minio.NewWithCredentials(cfg.Endpoint, creds, !cfg.UseHTTP, cfg.Region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "minio.NewWithCredentials")
|
return nil, errors.Wrap(err, "minio.NewWithCredentials")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue