Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Azure blob storage as backend #1149

Merged
merged 10 commits into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: go
sudo: false

go:
- 1.7.6
- 1.8.3
- tip

Expand All @@ -16,8 +15,6 @@ env:

matrix:
exclude:
- os: osx
go: 1.7.6
- os: osx
go: tip
- os: linux
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ Important Changes in 0.X.Y
vendoring the dependencies is now taken care of by `dep`.
https://github.com/restic/restic/pull/1126

* We've added support for Microsoft Azure Blob Storage as a restic backend.
https://github.com/restic/restic/pull/1149
https://github.com/restic/restic/pull/1059
https://github.com/restic/restic/issues/609

* In the course of supporting Microsoft Azure Blobe Storage Go 1.8 is now a
requirement to build restic.

Small changes
-------------

Expand Down
26 changes: 25 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ func (cs Constants) LDFlags() string {

func main() {
ver := runtime.Version()
if strings.HasPrefix(ver, "go1") && ver < "go1.7" {
fmt.Fprintf(os.Stderr, "Go version %s detected, restic requires at least Go 1.7\n", ver)
if strings.HasPrefix(ver, "go1") && ver < "go1.8" {
fmt.Fprintf(os.Stderr, "Go version %s detected, restic requires at least Go 1.8\n", ver)
os.Exit(1)
}

Expand Down
22 changes: 22 additions & 0 deletions cmd/restic/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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.Create(cfg.(azure.Config))
case "swift":
return swift.Open(cfg.(swift.Config))
case "b2":
Expand Down
27 changes: 27 additions & 0 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,33 @@ The number of concurrent connections to the B2 service can be set with the `-o
b2.connections=10`. By default, at most five parallel connections are
established.

Microsoft Azure Blob Storage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also store backups on Microsoft Azure Blob Storage. Export the Azure
account name and key as follows:

.. code-block:: console

$ export AZURE_ACCOUNT_NAME=<ACCOUNT_NAME>
$ export AZURE_ACCOUNT_KEY=<SECRET_KEY>

Afterwards you can initialize a repository in a container called `foo` in the
root path like this:

.. code-block:: console

$ restic -r azure:foo:/ init
enter password for new backend:
enter password again:

created restic backend a934bac191 at azure:foo:/
[...]

The number of concurrent connections to the B2 service can be set with the
`-o azure.connections=10`. By default, at most five parallel connections are
established.


Password prompt on Windows
~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Loading