mirror of
https://github.com/restic/restic.git
synced 2025-10-27 14:28:54 +00:00
Add Azure Blob Storage as backend
Environment variables: AZURE_ACCOUNT_NAME=storage-account-name AZURE_ACCOUNT_KEY=storage-account-key Environment variables for test: RESTIC_TEST_AZURE_ACCOUNT_NAME=storage-account-name RESTIC_TEST_AZURE_ACCOUNT_KEY=storage-account-key RESTIC_TEST_AZURE_REPOSITORY=azure:restic-test-container Init repository: $ restic -r azure:container-name:/prefix/dir init
This commit is contained in:
committed by
Alexander Neumann
parent
2c22ff175c
commit
3a85b6b7c6
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/restic/restic/internal/backend/azure"
|
||||
"github.com/restic/restic/internal/backend/b2"
|
||||
"github.com/restic/restic/internal/backend/local"
|
||||
"github.com/restic/restic/internal/backend/location"
|
||||
@@ -363,6 +364,23 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
|
||||
debug.Log("opening s3 repository at %#v", cfg)
|
||||
return cfg, nil
|
||||
|
||||
case "azure":
|
||||
cfg := loc.Config.(azure.Config)
|
||||
if cfg.AccountName == "" {
|
||||
cfg.AccountName = os.Getenv("AZURE_ACCOUNT_NAME")
|
||||
}
|
||||
|
||||
if cfg.AccountKey == "" {
|
||||
cfg.AccountKey = os.Getenv("AZURE_ACCOUNT_KEY")
|
||||
}
|
||||
|
||||
if err := opts.Apply(loc.Scheme, &cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
debug.Log("opening gs repository at %#v", cfg)
|
||||
return cfg, nil
|
||||
|
||||
case "swift":
|
||||
cfg := loc.Config.(swift.Config)
|
||||
|
||||
@@ -429,6 +447,8 @@ func open(s string, opts options.Options) (restic.Backend, error) {
|
||||
be, err = sftp.Open(cfg.(sftp.Config))
|
||||
case "s3":
|
||||
be, err = s3.Open(cfg.(s3.Config))
|
||||
case "azure":
|
||||
be, err = azure.Open(cfg.(azure.Config))
|
||||
case "swift":
|
||||
be, err = swift.Open(cfg.(swift.Config))
|
||||
case "b2":
|
||||
@@ -477,6 +497,8 @@ func create(s string, opts options.Options) (restic.Backend, error) {
|
||||
return sftp.Create(cfg.(sftp.Config))
|
||||
case "s3":
|
||||
return s3.Create(cfg.(s3.Config))
|
||||
case "azure":
|
||||
return azure.Open(cfg.(azure.Config))
|
||||
case "swift":
|
||||
return swift.Open(cfg.(swift.Config))
|
||||
case "b2":
|
||||
|
||||
Reference in New Issue
Block a user