-
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
restic prune
wipes repo if snapshot listing fails
#4612
Comments
Upon further investigation, I have discovered the following: Rclone's restic server's object list method responds with an inappropriate 404 if it encounters an error other than This is also inconsistent with restic/rest-server's behaviour where only On restic's end, 404 means that the directory doesn't exist and it isn't considered as an error, as per commit 307aeb6: restic/internal/backend/rest/rest.go Lines 330 to 333 in 8f9a357
Rclone encounters a connectivity issue and responds with a 404, which indicates that there are no snapshots, so restic prunes everything. I believe that this has to be fixed in rclone then, by responding with 500 instead of 404 in such cases. |
Oh, that's not good. I've opened rclone/rclone#7550 to fix the error handling in rclone. The PR contains an additional change to prepare for #4520 (which we might have to back out to give the rclone fix time to propagate). |
Btw, before restic 0.16.0, the rest backend did not ignore 404 errors while listing a directory. The change was introduced in #4400 . |
You could give the steps from https://restic.readthedocs.io/en/stable/077_troubleshooting.html a try to see whether there's anything left in the repository that can be salvaged. |
I did do that after the repo broke and managed to salvage everything other than some parts of the deleted data that wasn't healable due to the source files being changed, so some files in older snapshots will be corrupted, but other than that, the repository is fully operational without any errors. |
Output of
restic version
restic 0.16.0 compiled with go1.20.6 on windows/amd64
I'm aware that this is two releases behind the latest one (0.16.2) but there doesn't appear to be any fixes related to this issue in the newer releases.
What backend/service did you use to store the repository?
Storj (through rclone)
Problem description / Steps to reproduce
I ran
restic prune
, snapshot listing failed, maybe because of a connection issue, but restic assumed that there were 0 snapshots and started deleting everything from the repository. I stopped this withCtrl+C
as soon as I noticed it.Full Command:
restic prune --max-repack-size 1G --max-unused 0
Environment Variables:
RESTIC_REPOSITORY=rclone::storj,access_grant=redacted:restic
,RESTIC_PASSWORD=redacted
Command Output:
I ran the same command again after this, the output of which was as under, as expected:
Expected behavior
Restic should exit with exit code
1
if snapshot listing fails during a prune operation.Actual behavior
Restic deletes all data from the repository if snapshot listing fails during a prune operation.
Do you have any idea what may have caused this?
The snapshot listing probably failed because of a connection issue, but restic should have stopped after that.
Did restic help you today? Did it make you happy in any way?
Other than this issue I just ran into, restic has worked great for me. I have been using it on multiple systems to perform daily backups.
The text was updated successfully, but these errors were encountered: