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

**URL:** <https://kopia.discourse.group/t/find-which-snapshots-contains-specific-file-and-delete-if-possible/1287>\
**Category:** Support\
**Created:** [July 19, 2022, 1:13pm UTC](https://kopia.discourse.group/t/find-which-snapshots-contains-specific-file-and-delete-if-possible/1287 "2022-07-19T13:13:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xxxliqu1dxxx](https://avatars.discourse-cdn.com/v4/letter/x/f08c70/32.png) [@xxxliqu1dxxx](https://kopia.discourse.group/u/xxxliqu1dxxx)\
**Post date:** [July 19, 2022, 1:13pm UTC](https://kopia.discourse.group/t/find-which-snapshots-contains-specific-file-and-delete-if-possible/1287/1 "2022-07-19T13:13:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![basldfalksjdf](https://avatars.discourse-cdn.com/v4/letter/b/ce73a5/32.png) [@basldfalksjdf](https://kopia.discourse.group/u/basldfalksjdf)\
**Post date:** [July 19, 2022, 2:25pm UTC](https://kopia.discourse.group/t/find-which-snapshots-contains-specific-file-and-delete-if-possible/1287/2 "2022-07-19T14:25:23Z")

</div>

There is [content delete | Kopia](https://kopia.io/docs/reference/command-line/advanced/content-delete/) 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?

---

<div class="post-metadata">

**Author:** ![xxxliqu1dxxx](https://avatars.discourse-cdn.com/v4/letter/x/f08c70/32.png) [@xxxliqu1dxxx](https://kopia.discourse.group/u/xxxliqu1dxxx)\
**Post date:** [July 19, 2022, 5:08pm UTC](https://kopia.discourse.group/t/find-which-snapshots-contains-specific-file-and-delete-if-possible/1287/3 "2022-07-19T17:08:35Z")

</div>

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](https://kopia.discourse.group/u/basldfalksjdf) and @jkowalski for providing the command!

---

<div class="post-metadata">

**Author:** ![bbccdd](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/bbccdd/32/143_2.png) [@bbccdd](https://kopia.discourse.group/u/bbccdd)\
**Post date:** [March 8, 2023, 1:08pm UTC](https://kopia.discourse.group/t/find-which-snapshots-contains-specific-file-and-delete-if-possible/1287/4 "2023-03-08T13:08:41Z")

</div>

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.
