Merge pull request #184 from howeyc/backend-s3

Add Amazon S3 backend.
This commit is contained in:
Alexander Neumann
2015-06-23 20:14:47 +02:00
50 changed files with 10522 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/jessevdk/go-flags"
"github.com/restic/restic/backend"
"github.com/restic/restic/backend/local"
"github.com/restic/restic/backend/s3"
"github.com/restic/restic/backend/sftp"
"github.com/restic/restic/repository"
"golang.org/x/crypto/ssh/terminal"
@@ -127,6 +128,7 @@ func (o GlobalOptions) OpenRepository() (*repository.Repository, error) {
// Open the backend specified by URI.
// Valid formats are:
// * /foo/bar -> local repository at /foo/bar
// * s3://region/bucket -> amazon s3 bucket
// * sftp://user@host/foo/bar -> remote sftp repository on host for user at path foo/bar
// * sftp://host//tmp/backup -> remote sftp repository on host at path /tmp/backup
func open(u string) (backend.Backend, error) {
@@ -137,6 +139,8 @@ func open(u string) (backend.Backend, error) {
if url.Scheme == "" {
return local.Open(url.Path)
} else if url.Scheme == "s3" {
return s3.Open(url.Host, url.Path[1:])
}
args := []string{url.Host}
@@ -158,6 +162,8 @@ func create(u string) (backend.Backend, error) {
if url.Scheme == "" {
return local.Create(url.Path)
} else if url.Scheme == "s3" {
return s3.Open(url.Host, url.Path[1:])
}
args := []string{url.Host}