Skip to main content

restic snapshots

restic snapshots allows you to see all the point-in-time backups stored in your repository. It provides a unique ID for each backup, along with timestamps, hostnames, tags, and the paths that were backed up.

Quick Summary

If backup is saving your progress, snapshots is the "Load Game" menu. Use this command to find the specific ID you need for a restore or a deletion.

Basic Syntax

restic snapshots [flags] [snapshotID...]

Common Variations

# List all snapshots
restic snapshots

# Show the absolute latest snapshot
restic snapshots --latest 1

# Filter by hostname
restic snapshots --host server-prod

# Filter by tags
restic snapshots --tag daily

Key Flags

FlagDescription
--host HOSTNAMEOnly list snapshots for a specific host
--tag TAGOnly list snapshots with a specific tag (can be used multiple times)
--path PATHOnly list snapshots that contain a specific path
--latest NOnly show the last N snapshots
--jsonOutput the list in JSON format (useful for scripting)
--group-by columnsGroup snapshots by host, paths, or tags
--compactUse a more compact table format

Practical Examples

1. Finding the Latest Snapshot for a Specific Path

If you have multiple backups going to one repo, filter by path to find the right one.

restic snapshots --path /var/www/html --latest 1

2. Grouping Snapshots by Host

Useful when managing a central backup repository for many servers.

restic snapshots --group-by host

3. Filtering by Multiple Tags

Find snapshots that have both tags.

restic snapshots --tag production --tag database

4. Getting Snapshot IDs for Scripting

Use the --json flag to extract IDs using jq.

restic snapshots --json | jq -r '.[].id'

Understanding the Output

ColumnDescription
IDThe unique 8-character hash (short ID) of the snapshot.
TimeWhen the backup was completed.
HostWhich machine the data came from.
TagsCustom labels applied during backup.
PathsWhich local folders are contained in this snapshot.

Common Pitfalls

PitfallConsequencePrevention
Misinterpreting IDsAttempting to restore from the wrong point in time.Always verify the Time and Paths columns.
Too Many SnapshotsOutput becomes overwhelming and hard to read.Use --latest or --group-by to filter results.
Missing HostnamesHard to tell which server a snapshot belongs to if they share a default name.Always set a meaningful hostname via --host during backup.

Examples with Output

1. Standard Listing (All Snapshots)

Command:

restic snapshots

Output:

repository a7b2c9d opened successfully, password is correct
ID Time Host Tags Paths
-
d8f3e2a1 2024-01-10 12:00:00 app-01 daily /srv/data
f9e2d1c0 2024-01-11 12:00:00 app-01 daily /srv/data
a1b2c3d4 2024-01-11 15:30:00 db-01 manual /var/lib/mysql
-
3 snapshots

2. Filtering by Host and Tag

Command:

restic snapshots --host app-01 --tag daily

Output:

repository a7b2c9d opened successfully, password is correct
ID Time Host Tags Paths
-
d8f3e2a1 2024-01-10 12:00:00 app-01 daily /srv/data
f9e2d1c0 2024-01-11 12:00:00 app-01 daily /srv/data
-
2 snapshots

3. Compact View (Filtered by Path)

Command:

restic snapshots --path /srv/data --compact

Output:

ID        Time                 Host        Tags        Paths
-
d8f3e2a1 2024-01-10 12:00:00 app-01 daily /srv/data
f9e2d1c0 2024-01-11 12:00:00 app-01 daily /srv/data
-

4. Latest N Snapshots

Command:

restic snapshots --latest 1

Output:

repository a7b2c9d opened successfully, password is correct
ID Time Host Tags Paths
-
a1b2c3d4 2024-01-11 15:30:00 db-01 manual /var/lib/mysql
-
1 snapshots

5. JSON Output (Programmatic)

Command:

restic snapshots --latest 1 --json

Output:

[
{
"time": "2024-01-11T15:30:00.000000000Z",
"tree": "b4a3c2d1...",
"paths": ["/var/lib/mysql"],
"hostname": "db-01",
"username": "root",
"uid": 0,
"gid": 0,
"tags": ["manual"],
"id": "a1b2c3d4...",
"short_id": "a1b2c3d4"
}
]

What's Next?

Compare what changed between snapshots with restic diff or inspect files with restic ls.