How does forget work for snapshots with different paths?

If I have previous snapshots with files at a different path then my latest snapshot will forgetting the previous snapshots remove the files from my repo?

Example

If I started with directories and files underneath them:

foo/a
foo/b
bar/c

and I had them backed up in 2 different snapshots, one with a root of foo and another bar.

Since then I’ve moved files to a new server, so now my paths are under a parent:

parent/foo/a
parent/foo/b
parent/bar/c
parent/new/d

I have a snapshot that includes parent and all of its child directories. When making this snapshot, Restic couldn’t find a parent snapshot, so it rescanned all the files but it looks like the de-dup worked and it only added d since it found checksums for the other files.

If I forget the foo and bar snapshot, will I lose the files a, b, and c from my repo, or does the content remain?

Hi @jamesfm , I think your post does not make clear which content you have in which snapshots, so I will give a more generic answer.

When you forget one or more snapshots, only data unique to those snapshots will be forgotten.

1 Like

If the four lines you show above represents four different snapshots (one per line), and you remove the first three snapshots (only leaving one snapshot for parent/new/d), then if you after that run the prune command, the repository will only contain data for the files that are referenced in the remaining snapshot. Does that answer your question?

To be more specific, the forget command only removes snapshots, not the actual data that was referenced by those snapshots in the repository. The latter is removed when you run the prune command. But of course only the data that is no longer referenced by any of the remaining snapshot(s) is removed, such that the remaining snapshot still has all the data for all the files that it references (in other words, the files that you backed up when creating that snapshot).

Thanks for the answers, I think it covers what I was looking for. My understanding is that data will remain because it’s considered part of the latest snapshots.

But just for clarity, in my example the first two snapshots are:

Snapshot 1

foo/a
foo/b

Snapshot 2

bar/c

And the last / latest snapshot:

Snapshot 3

parent/foo/a
parent/foo/b
parent/bar/c
parent/new/d