Backup parent folder doesn't "see" previous backups

If I perform these two backups, the 2nd backup, which is just parent folder, doesn’t seem to recognize that the sub-folder has already been backed up in the 1st backup.

restic backup "/data/sub1/"
no parent snapshot found, will read all files
Files:         100 new,     0 changed,     0 unmodified
Dirs:           10 new,     0 changed,     0 unmodified
restic backup "/data/"
no parent snapshot found, will read all files
Files:         300 new,     0 changed,     0 unmodified
Dirs:           30 new,     0 changed,     0 unmodified

I would expect the 2nd backup would say:

Files:         200 new,     0 changed,     100 unmodified
Dirs:           20 new,     0 changed,      10 unmodified

Why is that?

The parent selection algorithm only selects snapshots with exactly identical path.
You can manually specify the parent using --parent.

See also

or (with still just one possible parent snapshot):

But the files do have the exact the same path?

E.g. the file /data/sub1/file1.txt will be covered by both backups so it should not be backed up twice.

Yes, but this is irrelevant when taking a backup. You specify a path and when you make another backup with the same path the previous backup with that path is chosen as the parent (given there is one already). The data in the backup is still de-duplicated and all the things you expect. The files are not backed up twice as in twice the amount of storage space for the backed up files - Restic still knows this.

2 Likes