Hi, I recently found that the download folder slipt into some of my backups, and I wanted to rewrite them to not have it anymore, though the restic rewrite fails with the message in the subject.
The ID printed is not reproducible across tries and changes:
$ RESTIC_COMPRESSION=max restic rewrite --exclude='Downloads/*'
repository 46211214 opened (version 2, compression level max)
snapshot 0a877585 of [/home/nmelzer] at 2023-05-20 01:00:13.880221453 +0200 CEST)
could not load snapshots: context canceled
Fatal: unable to rewrite snapshot ID "0a877585": cannot encode tree at "/" without loosing information
Tried that, and it seems as if that doesn’t work either:
$ RESTIC_COMPRESSION=max restic rewrite --exclude='/home/nmelzer/Downloads/*'
repository 46211214 opened (version 2, compression level max)
snapshot 08a5e216 of [/home/demo] at 2022-01-25 22:15:54.804224483 +0100 CET)
could not load snapshots: context canceled
Fatal: unable to rewrite snapshot ID "08a5e216": cannot encode tree at "/home/demo" without loosing information
$ RESTIC_COMPRESSION=max restic rewrite --exclude='/home/nmelzer/Downloads/*' --host mimas
repository 46211214 opened (version 2, compression level max)
snapshot 0a877585 of [/home/nmelzer] at 2023-05-20 01:00:13.880221453 +0200 CEST)
could not load snapshots: context canceled
Fatal: unable to rewrite snapshot ID "0a877585": cannot encode tree at "/" without loosing information
$ RESTIC_COMPRESSION=max restic rewrite --exclude='/home/nmelzer/Downloads' --host mimas
repository 46211214 opened (version 2, compression level max)
snapshot 0a877585 of [/home/nmelzer] at 2023-05-20 01:00:13.880221453 +0200 CEST)
could not load snapshots: context canceled
Fatal: unable to rewrite snapshot ID "0a877585": cannot encode tree at "/" without loosing information
And why isn’t in the first run the snapshot not just skipped, as it clearly does not contain any paths to rewrite…
Also, isn’t “loosing information” kind of what we expect from a rewrite?
Or might this be related to that fact that backups are actually created using rustic rather than restic and there is some metadata that restic can not properly move?
Add some test directory to your repo - then check if you can rewrite it. If no then there is repo problem, if yes then it would point to some “issue” in Downloads folder.
The snapshots on which the rewrite fail for me seems to be a snapshots that was copied from one repository to another.
snapshot a33a1f45 of [/home/user] at 2023-04-25 17:33:42.700107197 +0200 CEST)
could not load snapshots: context canceled
Fatal: unable to rewrite snapshot ID "a33a1f45": cannot encode tree at "/" without loosing information
restic -r sftp:someRemoteRepo snapshots a33a1f45 --json
enter password for repository:
[{"time":"2023-04-25T17:33:42.700107197+02:00","tree":"984af441a9e5de8de4eb27ab9b9a39c3fe38d57c597a9aad42585d4d3f304d18","paths":["/home/user"],"hostname":"<anotherHost>","original":"1c93a52c6a8359c6ccc3b58dd1ee11d60cd1e46f4b1b69ae90f5f9198954eafb","id":"a33a1f4591ea5864398b17fad185cf77d290eca18ef717a1f7ab47e80d8d9f81","short_id":"a33a1f45"}]
edit:
Even running the command restic -r sftp:someRemoteRepo rewrite --dry-run --exclude-file /tmp/exclude a33a1f45 with an empty excludeFile fails
That is likely the cause. rewrite verifies that saving the unmodified tree metadata would exactly recreate the existing metadata. That ensures that there are no unexpected changes to a snapshot during a rewrite. In restic 0.16.0 (or using a beta build) restic repair snapshots will be able to fix the problem.
@wnklmnn What is the output of restic cat blob 984af441a9e5de8de4eb27ab9b9a39c3fe38d57c597a9aad42585d4d3f304d18? The problems with rewriting the snapshot show up while processing that (tree) blob.