Find which snapshots contains specific file (and delete if possible)

Hi everyone,

Is there a CLI command that allows searching all snapshots for a specific file and/or path and take action for it?

My use case is: I know I have a file called xxxx.yyy and I want to search which user@path has snapshotted this file and then delete it.

In addition, if I do not know the precise filename or extension - is there a similar or the same command that would allow searching for patterns and include wildcards? i.e. search all user@path snapshots for %xxx%.% or xxx.*

Finally, if such snapshot contain that file and/or path, is there a way to scrub that single file or folder from that particular snapshot? I do not want to delete the whole snapshot, but just this specific file and/or path.

Thanks!

There is content delete | Kopia but for that you need to know the content ID, which is not what you want to do.

Having a feature as you describe would be great. Maybe submit a FR?

I’ve been informed that the deletion portion of this use case is possible with the kopia snapshot fix remove-files command. It does not search, but knowing the specific filename and plugging it as a parameter does indeed delete that file and adding --commit updates the snapshots meeting my requirement.
Awesome - thanks basldfalksjdf and @jkowalski for providing the command!

2 Likes

Works great with just a filename and a source indeed!

Example

root@host:~# kopia snapshot fix remove-files --commit --source=“root@server:/path/to/snapshot” --filename=“IMG_2825.MOV”
Listing snapshots for source “root@server:/path/to/snapshot”…
Processing snapshot root@server:/path/to/snapshot
2023-01-31 06:25:02 CET unchanged (bd7dbc881f810efd71e67bd48c06de45)
will remove file familyalbum/2021 smartphone/IMG_2825.MOV/IMG_2825.MOV
2023-03-08 10:45:59 CET replaced manifest from 8974a45b99bec40f29e8af0f911de597 to 483a24753a4758d89fa5b969cbe7b23d
diff k98b59bff88da18ee47e819ff7cf896e60a2947b9bc58e6abb6151453ad668803 k608dee4d8f5cc99de1ec1b918c45e6c310ba1f65cd3709cdb96190c64f9c94fe
delta:-3.7 MB
2023-03-08 10:46:57 CET replaced manifest from a75f12532afac87505c70ee2f7be2c8e to a47f89b6dffb9b1b770e4e925a956800
diff k98b59bff88da18ee47e819ff7cf896e60a2947b9bc58e6abb6151453ad668803 k608dee4d8f5cc99de1ec1b918c45e6c310ba1f65cd3709cdb96190c64f9c94fe
delta:-3.7 MB
Fixed and committed 2 snapshots.

Can one also specify a path or does this only work with filenames? Tried using globbing e.g., ‘*directory1/directory2/filename.ext’ but that does not work.