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
| Flag | Description |
|---|---|
--host HOSTNAME | Only list snapshots for a specific host |
--tag TAG | Only list snapshots with a specific tag (can be used multiple times) |
--path PATH | Only list snapshots that contain a specific path |
--latest N | Only show the last N snapshots |
--json | Output the list in JSON format (useful for scripting) |
--group-by columns | Group snapshots by host, paths, or tags |
--compact | Use 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
| Column | Description |
|---|---|
| ID | The unique 8-character hash (short ID) of the snapshot. |
| Time | When the backup was completed. |
| Host | Which machine the data came from. |
| Tags | Custom labels applied during backup. |
| Paths | Which local folders are contained in this snapshot. |
Common Pitfalls
| Pitfall | Consequence | Prevention |
|---|---|---|
| Misinterpreting IDs | Attempting to restore from the wrong point in time. | Always verify the Time and Paths columns. |
| Too Many Snapshots | Output becomes overwhelming and hard to read. | Use --latest or --group-by to filter results. |
| Missing Hostnames | Hard 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.