Latest snapshot for criteria not found: no snapshot found

Hi

I’m trying to restore data from the latest snapshot but, for some reasons, it appears that restic does not find the data:

# restic --cacert znas-ca.crt -r s3:https://znas.lan:9000/restic --cache-dir /restic/cache ls latest
...
/storec1/axapi1/=user/04/b3/=grace/=+Sent/00/50.msg
/storec1/axapi1/=user/04/b3/=grace/=+Sent/00/51.msg
/storec1/axapi1/=user/04/b3/=grace/=+Sent/00/52.msg
...
[tons of results]
...

So, I guess the “grace” user has some files in his subdirs backuped in the snapshot, right? But if I try to restore those files:

# restic --cacert znas-ca.crt -r s3:https://znas.lan:9000/restic --cache-dir /restic/cache restore latest --path "/storec1/axapi1/=user/04/b3/=grace" --target /tmp/restic-restore/
enter password for repository:
repository e9685a0a opened successfully, password is correct
latest snapshot for criteria not found: no snapshot found Paths:[/storec1/axapi1/=user/04/b3/=grace] Host:

BTW, if I try to search for grace (find -s 0fad4d90 grace), restic returns nothing.

Maybe the ‘=’ characters in the path are not well supported? Do I misunderstand how to restore the data? Thanks for you help!

Olivier

@olc if you list the snapshots with restic snapshots and locate the one you want (it will display the path for each), then your can restore that snapshot identifying it by the snapshot id rather than the latest for a path.

I don’t know why the path isn’t matching.

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