-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
azure: Unable to init repo when using container-level SAS (SAT) #4004
Comments
Just ignoring the permission error when creating the container, should probably just work. The S3 backend does something similar: restic/internal/backend/s3/s3.go Lines 142 to 145 in 8dd95b7
If the access token is missing privileges, then creating the |
I can confirm that ignoring the error does just work. I chucked a check in the 162 } else if err != nil && bloberror.HasCode(err, bloberror.AuthorizationFailure) {
163 debug.Log(" Cannot call GetProperties due to AuthorizationFailure. Ignoring - see Issue #4004")
164 err = nil
165 } If this is the approach you want to take with the project, I can do a pull request for the change; if not I don't mind because I'm happy to patch my version of restic as needed. |
Ignoring access denied errors when creating the container should be fine. We're already doing something similar in the S3 backend (see restic/internal/backend/s3/s3.go Line 201 in bcd5ac3
So, yes we'd be interested in a PR :-) . |
Add changelog entry in the 'unreleased' sub-folder for changes introduced when fixing issue restic#4004.
OK, I will/I have done a PR for this, after tidying it up to have tests and such. |
Add changelog entry in the 'unreleased' sub-folder for changes introduced when fixing issue restic#4004.
Add changelog entry in the 'unreleased' sub-folder for changes introduced when fixing issue restic#4004.
Output of
restic version
restic 0.14.0 (v0.14.0-234-g9354262b1-dirty) compiled with go1.19 on darwin/amd64
How did you run restic exactly?
What backend/server/service did you use to store the repository?
Azure Blob Storage
Expected behavior
Actual behavior
Steps to reproduce the behavior
In Azure Blob Storage, create a Storage Account, then in that SA create a Container, and in that Container create a Shared Access Token (which is basically the same thing as a Shared Access Signature that you can create on the Storage Account level), then run the commands above.
Do you have any idea what may have caused this?
This has nothing to do with the
/backup
path in the example - the symptoms are the same even with justazure:containername:/
as the repository.The problem seems to be that when using a SAS/SAT on the container level, there is no permission to perform actions that have to do with creating the container - the SAS/SAT is only allowed to poke around inside the existing container, which makes sense.
The Azure library restic uses calls
container.CreateIfNotExists
which is where things fail, because it tries to create a container, which is denied.Do you have an idea how to solve the issue?
In order to support SAS/SAT on a container level we must make the code not attempt to create a container (or similar), and instead just presume that it is there. The entire SAS/SAT can not have been created without the container already existing, in this case.
I guess we have two options to handle this:
create(ctx, repo, gopts.extended)
), ignore this and somehow instantiate a backend anyway, then carry on and try to initialize a repository at that backend (s.Init(ctx, version, gopts.password, chunkerPolynomial)
). Not sure how feasible and clean this is.AZURE_ACCOUNT_SAS
value and determine if it's an account- or container-level SAS/SAT, and depending on that do or skip the backend creation before initializing a repository on the backend. We'd still need to instantiate a backend in the code, so I'm not sure how to do that cleanly either. Perhaps it's simple.Did restic help you today? Did it make you happy in any way?
Always 👍
EDIT: A workaround is to temporarily use an account-level SAS (or the regular account key, if one fancies that instead) for the
restic init
and after that use the container-level SAS/SAT as usual for the other restic commands (works fine since they won't try to create the container).The text was updated successfully, but these errors were encountered: