Missing snapshots

I’m new to restic and doing some experimenting with BASH scripts for backup in my home network.
I have something I don’t understand about snapshots that I appear to have created in a backup, but “latest” only shows an older snapshot.
Searching for the snapshot using the ID can’t find it.

~> $ ~/Downloads/Prog/test.sh
open repository
repository 74609cc9 opened (version 2, compression level auto)
no parent snapshot found, will read all files
load index files
[0:00] 100.00%  12 / 12 index files loaded
start scan on [/home/clarence/Documents/politics]
start backup on [/home/clarence/Documents/politics]
scan finished in 0.070s: 6 files, 176.631 KiB

Files:           6 new,     0 changed,     0 unmodified
Dirs:            4 new,     0 changed,     0 unmodified
Data Blobs:      4 new
Tree Blobs:      5 new
Added to the repository: 179.749 KiB (7.022 KiB stored)

processed 6 files, 176.631 KiB in 0:01
snapshot abc5c476 saved

*▀▀ ~> $ restic -v snapshots latest
repository 7805006a opened (version 2, compression level auto)
ID        Time                 Host        Tags        Paths                   Size
------------------------------------------------------------------------------------------
e10ccdf6  2025-08-25 16:55:00  NUCbox-k4               /home/clarence/Desktop  371.609 MiB
------------------------------------------------------------------------------------------
1 snapshots

*▀▀ ~> $ restic ls abc5c476
repository 7805006a opened (version 2, compression level auto)
[0:00] 100.00%  15 / 15 index files loaded
no matching ID found for prefix "abc5c476"
*▀▀ ~> $ 

I’m not sure whether the backup is working without a snapshot to prove it.

We don’t know what is in the script where you hide the restic backup commands, so when asking a question you should always be elaborate and show that too (i.e. the contents of ~/Downloads/Prog/test.sh).

That said, look at the lines repository … opened in the output from ~/Downloads/Prog/test.sh as well as in the output from the other restic commands. You will spot the difference, and this difference is the reason you are seeing the symptoms you describe/show :slight_smile:

Here is the script. I have been unsuccessfully so far trying to make it work with cron. The “touches” were just to prove the script ran.

#!/bin/bash
 
export RESTIC_REPOSITORY=sftp:clarence@Nucbox5:/mnt/raid/back/resticCP
export RESTIC_PASSWORD=password	


touch ~/Downloads/Prog/testfile.txt

restic backup -v /home/clarence/Documents/politics
touch ~/Downloads/Prog/testfile2.txt

Thanks! The answer is still the same though. Look at the repository IDs in the output.

I just looked at the “snapshots” directory in the repository and see one withe the correct time. I can’t decode the name, but the first 8 characters match the ID from the backup. The snapshot appears to have a life in here somehow, but there are only 12 snapshot files and at least 16 snapshots.

It seems you are not reading what I suggested earlier. I will spell it out for you:

This:

~> $ ~/Downloads/Prog/test.sh
open repository
repository 74609cc9 opened (version 2, compression level auto)

And this:

*▀▀ ~> $ restic -v snapshots latest
repository 7805006a opened (version 2, compression level auto)

Contain two different repository IDs (74609cc9 and 7805006a). This shows that the first command is opening one repository, and the second and third command is opening another, different, repository.

The restic -v snapshots latest command is not seeing the snapshot from the backup made by the ~/Downloads/Prog/test.sh command simply because they are looking into two different repositories.

Sometimes you have to beat me over the head with it. Is there a quick way to get the repository ID?

I’m not sure how you mean? The repository ID is the one shown in the output I referred to above.

Which repository restic uses is controlled by the RESTIC_REPOSITORY environment variable, or the --repo option or similar to the restic command. You probably have different values for the environment variable in the shell where you run the second and third command, than what’s in the script.

I really thank you.
The script forces the ID to use and the other commands fall back to whatever is in .bashrc.

Yeah, although to be more accurate, the ID is really just an identifier for the repository. You don’t specify which repository to use by specifying an ID, you specify a connection string that we call the “repository URL”.

Very glad it worked out!