Latest snapshot for criteria not found: no snapshot found

The --path option to restore requires passing a path which is listed in the snapshot itself (what restic snapshots print). This does not mean the directory structure within a snapshot.

I’ll try to describe an example: Let’s say there’s a file called test.txt in /srv/data/tmp/work, and this is saved with restic like this:

$ restic backup /srv/data/tmp/work
[...]
processed 1 files, 4 B in 0:00
snapshot e6a5f38f saved

For this snapshot, the path is /srv/data/tmp/work, because it’s absolute restic just records it in the snapshot, as seen here:

$ restic snapshots
ID        Date                 Host        Tags        Directory
----------------------------------------------------------------------
e6a5f38f  2018-09-02 12:31:42  mopped                  /srv/data/tmp/work
----------------------------------------------------------------------
1 snapshots

As the path is absolute, restic added all directories as the structure within the snapshot:

$ restic ls -l latest
snapshot e6a5f38f of [/srv/data/tmp/work] filtered by [] at 2018-09-02 12:31:42.322955972 +0200 CEST):
drwxr-xr-x     0     0      0 2018-04-25 13:18:49 /srv
drwxr-xr-x  1000     0      0 2018-04-14 12:54:21 /srv/data
drwxr-xr-x  1000   100      0 2018-09-02 12:30:55 /srv/data/tmp
drwxr-xr-x  1000   100      0 2018-09-02 12:30:59 /srv/data/tmp/work
-rw-r--r--  1000   100      4 2018-09-02 12:30:59 /srv/data/tmp/work/test.txt

And we can verify that by supplying the path /srv/data/tmp/work as the option to --path (it must match exactly, so no trailing slashes etc) indeed finds the snapshot:

$ restic snapshots --path /srv/data/tmp/work
ID        Date                 Host        Tags        Directory
----------------------------------------------------------------------
e6a5f38f  2018-09-02 12:31:42  mopped                  /srv/data/tmp/work
----------------------------------------------------------------------
1 snapshots

You can control how the data structures within the snapshot looks like by using relative paths. For example, you can make the work directory the top-level directory by calling restic like this:

$ cd /srv/data/tmp
$ restic backup work
processed 1 files, 4 B in 0:00
snapshot 91768ea8 saved

$ restic ls -l latest
snapshot 91768ea8 of [/srv/data/tmp/work] filtered by [] at 2018-09-02 12:35:31.176588304 +0200 CEST):
drwxr-xr-x  1000   100      0 2018-09-02 12:30:59 /work
-rw-r--r--  1000   100      4 2018-09-02 12:30:59 /work/test.txt

In the snapshot, restic will still note that /srv/data/tmp/work has been saved, so it can find this snapshot again the next time it is called:

$ restic snapshots
ID        Date                 Host        Tags        Directory
----------------------------------------------------------------------
e6a5f38f  2018-09-02 12:31:42  mopped                  /srv/data/tmp/work
91768ea8  2018-09-02 12:35:31  mopped                  /srv/data/tmp/work
----------------------------------------------------------------------
2 snapshots

In all cases, the argument to --path must be the path that is listed in the Directory column of restic snapshots.

In conclusion, it’s probably the best to pass the snapshot ID (in the first column above) to restic restore, so you can be sure what’s restored.

2 Likes