2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00
restic/internal
Michael Pratt fa0be82da8 gs: allow backend creation without storage.buckets.get
If the service account used with restic does not have the
storage.buckets.get permission (in the "Storage Admin" role), Create
cannot use Get to determine if the bucket is accessible.

Rather than always trying to create the bucket on Get error, gracefully
fall back to assuming the bucket is accessible. If it is, restic init
will complete successfully. If it is not, it will fail on a later call.

Here is what init looks like now in different cases.

Service account without "Storage Admin":

Bucket exists and is accessible (this is the case that didn't work
before):

$ ./restic init -r gs:this-bucket-does-exist:/
enter password for new backend:
enter password again:
created restic backend c02e2edb67 at gs:this-bucket-does-exist:/

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.

Bucket exists but is not accessible:

$ ./restic init -r gs:this-bucket-does-exist:/
enter password for new backend:
enter password again:
create key in backend at gs:this-bucket-does-exist:/ failed:
service.Objects.Insert: googleapi: Error 403:
my-service-account@myproject.iam.gserviceaccount.com does not have
storage.objects.create access to object this-bucket-exists/keys/0fa714e695c8ecd58cb467cdeb04d36f3b710f883496a90f23cae0315daf0b93., forbidden

Bucket does not exist:

$ ./restic init -r gs:this-bucket-does-not-exist:/
create backend at gs:this-bucket-does-not-exist:/ failed:
service.Buckets.Insert: googleapi: Error 403:
my-service-account@myproject.iam.gserviceaccount.com does not have storage.buckets.create access to bucket this-bucket-does-not-exist., forbidden

Service account with "Storage Admin":

Bucket exists and is accessible: Same

Bucket exists but is not accessible: Same. Previously this would fail
when Create tried to create the bucket. Now it fails when trying to
create the keys.

Bucket does not exist:

$ ./restic init -r gs:this-bucket-does-not-exist:/
enter password for new backend:
enter password again:
created restic backend c3c48b481d at gs:this-bucket-does-not-exist:/

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
2017-09-25 22:25:51 -07:00
..
archiver Merge pull request #1243 from restic/improve-error-reporting 2017-09-16 14:54:30 +02:00
backend gs: allow backend creation without storage.buckets.get 2017-09-25 22:25:51 -07:00
cache cache: Synchronize downloading 2017-09-25 15:58:20 +02:00
checker tests updated 2017-09-09 13:26:35 +02:00
crypto internal/crypto: small simplifications 2017-08-29 00:30:06 +02:00
debug Run goimports 2017-07-23 14:21:03 +02:00
errors Moves files 2017-07-23 14:19:13 +02:00
filter filter: document recursive wildcards 2017-09-04 14:38:48 -07:00
fs local: Fix creating data dirs 2017-09-11 21:48:25 +02:00
fuse fuse: added symlink 'latest' to snapshots-dir 2017-09-21 16:41:20 +02:00
hashing Moves files 2017-07-23 14:19:13 +02:00
index Move restic package to internal/restic 2017-07-24 17:43:32 +02:00
list Move restic package to internal/restic 2017-07-24 17:43:32 +02:00
migrations Move restic package to internal/restic 2017-07-24 17:43:32 +02:00
mock Move restic package to internal/restic 2017-07-24 17:43:32 +02:00
options Run goimports 2017-07-23 14:21:03 +02:00
pack Move restic package to internal/restic 2017-07-24 17:43:32 +02:00
pipe Run goimports 2017-07-23 14:21:03 +02:00
repository repo: Automatically cache tree-only pack files 2017-09-24 23:11:23 +02:00
restic Correct debug message 2017-09-25 14:35:37 +02:00
test internal: check error before deferring file Close() 2017-08-13 19:28:13 +02:00
walk tests updated 2017-09-09 13:26:35 +02:00
worker Run goimports 2017-07-23 14:21:03 +02:00