No matching ID found for prefix

Hello,

what is wrong with this? Why is it not working?

mostRecentSnapshots=$(restic snapshots --latest 1 --no-lock --json | jq -r '[.[].short_id] | join(" ")')
# RESTIC_FROM_REPOSITORY, RESTIC_REPOSITORY etc are set.
restic copy --no-lock "${mostRecentSnapshots}"

It gives me the following error:

Ignoring "3dfc43c9 7eac1759": no matching ID found for prefix "3dfc43c9 7eac1759"

I am using

jq --version
jq-1.7

and

restic version
restic 0.16.4 compiled with go1.22.2 on linux/amd64

Thanks a lot :slight_smile:

It is most likely problem with your jq skills and not with restic:)

Post result of

restic snapshots --latest 1 --no-lock --json 

and indicate what exactly you want to extract.

then simply debug it step by step by running:

restic snapshots --latest 1 --no-lock --json | jq -r '[.[].short_id] 

and then

restic snapshots --latest 1 --no-lock --json | jq -r '[.[].short_id] | join(" ")'

It should show you immediately where the issue is.

I want to copy all “latest” snapshots from one repo to another repo.

I don’t see any error in the yq command. I have been debugging this already intensively. The qt command extracts the short ids for all “latest” snapshots.

$ echo "${mostRecentSnapshots}"
3dfc43c9 7eac1759

$ restic copy --from-repo <source> "${mostRecentSnapshots}"  # does not work
enter password for source repository: 
repository 5508de08 opened (version 2, compression level auto)
repository 47a8ce99 opened (version 2, compression level auto)
[0:08] 100.00%  801 / 801 index files loaded
[0:07] 100.00%  801 / 801 index files loaded
Ignoring "3dfc43c9 7eac1759": no matching ID found for prefix "3dfc43c9 7eac1759"

$ restic copy --from-repo <source> 3dfc43c9 7eac1759  # works
enter password for source repository: 
repository 5508de08 opened (version 2, compression level auto)
repository 47a8ce99 opened (version 2, compression level auto)
[0:07] 100.00%  801 / 801 index files loaded
[0:07] 100.00%  801 / 801 index files loaded

Ok. Looks like some shell problem. can you try:

$ echo "${mostRecentSnapshots}"
3dfc43c9 7eac1759

$ restic copy --from-repo <source> '${mostRecentSnapshots}'

There are not shell expansions in '. This will result in Ignoring "${mostRecentSnapshots}": no matching ID found for prefix "${mostRecentSnapshots}"

:-/

Indeed. My wrong.

Is this still a problem? I don’t see what is unclear or I am misunderstanding what you’re asking.

If you have a string with two separate words in it, and you want those two words to become each their own argument, then you shan’t quote the variable (as if you do quote it, the shell will treat it as one single argument).

So running restic copy --from-repo <source> $mostRecentSnapshots is what you want to do, no?

2 Likes

thanks that did the trick :slight_smile:

1 Like