I had an issue on the weekend where the backup command, running in a docker container:

restic backup /shared

Would always report that all files were new, but when run repeatedly in the same container would work a treat.

Thanks to - https://forum.restic.net/t/running-restic-in-docker-always-causes-files-to-be-identified-as-new/2757/5 - it was easy to spot that this problem is because even though you might use --name to name the docker container the same, internally its a random hostname each time.

This means that restic thinks that each one is a different host, and so even though it does de-duplicate, it means that forgetting snapshots and pruning will be weird. So the listing of snapshots before was like this:

$ restic snapshots
repository 7973eaa7 opened successfully, password is correct
ID        Time                 Host          Tags        Paths
----------------------------------------------------------------
877a98c9  2020-08-23 18:46:17  9573bd241532              /shared
b04c906f  2020-08-23 18:48:38  a483d434e6a6              /shared
f32b16a0  2020-08-23 18:51:56  4b7dc6ada517              /shared
[snip]
a8a3efc2  2020-08-23 19:18:45  1a8c74abb2d6              /shared
----------------------------------------------------------------
9 snapshots

Luckily, the easy fix is to use the --host command option to restic, or add the --hostname to the docker container so that its the same for every run:

Then the output becomes much more reasonable:

$ restic snapshots
repository 2b4d35b9 opened successfully, password is correct
ID        Time                 Host               Tags        Paths
---------------------------------------------------------------------
28121abd  2020-08-24 19:15:47  docker_restic                  /shared
5e4c860f  2020-08-24 19:17:38  docker_restic                  /shared
717f89cc  2020-08-24 19:18:12  docker_restic                  /shared
[snip]
738ca4c0  2020-08-24 19:26:11  docker_restic                  /shared
---------------------------------------------------------------------
7 snapshots

The results when doing backups also look much more sensible:

open repository
repository 2b4d35b9 opened successfully, password is correct
lock repository
load index files
using parent snapshot 738ca4c0
start scan on [/shared]
start backup on [/shared]
scan finished in 8.908s: 146 files, 16.395 MiB

Files:           0 new,     1 changed,   145 unmodified
Dirs:            0 new,     0 changed,     0 unmodified
Data Blobs:      3 new
Tree Blobs:      1 new
Added to the repo: 12.659 MiB

processed 146 files, 16.395 MiB in 0:33
snapshot 58af6dc8 saved