restic cat
restic cat is a utility command used to display the contents of files stored within the repository without restoring them to disk. It can also be used to inspect internal Restic metadata like configuration blobs, master keys, and snapshots.
cat is for "Quick Peeks." If you just need to check one line in a configuration file or see the JSON data of a snapshot, cat is the fastest method.
Basic Syntax
# To view a backed-up file
restic cat snapshot [id] [path]
# To view repository metadata
restic cat [masterkey|config|snapshot|index] [id]
Usage Examples
# Print a backed-up config file
restic cat latest /etc/nginx/nginx.conf
# View the raw JSON of a snapshot (metadata)
restic cat snapshot d8f3e2a1
# View the repository configuration
restic cat config
Practical Examples
1. Checking a File Version
Quickly see if the version of a file in the latest backup has the change you're looking for.
restic cat latest /home/user/app/version.txt
2. Piping to other tools
Since cat outputs to stdout, you can pipe it to grep, awk, or even tar.
# Search for a string in a backed-up file
restic cat latest /var/log/syslog | grep "ERROR"
3. Inspecting Snapshot Metadata for Scripting
Use jq to extract the exact timestamp or tags from a snapshot's internal record.
restic cat snapshot latest | jq -r '.time'
cat vs restore vs mount
| command | goal | overhead |
|---|---|---|
cat | View content or metadata | Minimal (Stdout only) |
restore | Extract file to disk | High (Full decryption to disk) |
mount | Browse and read | Medium (FUSE latency) |
Common Pitfalls
| Pitfall | Consequence | Prevention |
|---|---|---|
| Catting Binary Files | Corrupts your terminal display with garbage characters. | Only cat text-based files like .conf, .sh, .txt. |
| Huge Files | Floods the terminal with millions of lines. | Use `restic cat ... |
| Forgetting the Type | restic cat d8f3e1 will fail because you didn't specify if it's a snapshot or blob. | Always use the type keyword for metadata: restic cat snapshot [ID]. |
Examples with Output
1. Simple File Content View
Command:
restic cat snapshot latest /etc/hostname
Output:
repository a7b2c9d opened successfully, password is correct
web-server-prod-01
2. View Repository Config
Command:
restic cat config
Output:
repository a7b2c9d opened successfully, password is correct
{
"version": 2,
"id": "a7b2c9d4e5f6...",
"chunker_polynomial": "36cd...",
"kdf": {
"N": 16384,
"r": 8,
"p": 1,
"salt": "..."
}
}
3. Piping Content to Grep
Command:
restic cat snapshot latest /var/log/syslog | grep "ERROR" | head -n 3
Output:
repository a7b2c9d opened successfully, password is correct
Jan 01 10:00:00 server ERROR: Connection refused
Jan 01 10:00:01 server ERROR: Retry failed
Jan 01 10:00:02 server ERROR: Giving up
4. Inspecting a Master Key
Command:
restic cat key 1a2b3c4d
Output:
repository a7b2c9d opened successfully, password is correct
{
"mac": { "k": "...", "r": "..." },
"encrypt": "...",
"created": "2024-01-01T12:00:00Z",
"username": "rezriz",
"hostname": "laptop"
}
5. Inspecting Index Blob
Command:
restic cat index 2b3c4d5e
Output:
repository a7b2c9d opened successfully, password is correct
{
"supersedes": null,
"packs": [
{
"id": "...",
"blobs": [
{ "id": "...", "type": "data", "offset": 0, "length": 4512 }
]
}
]
}
What's Next?
Find the files you want to "cat" using restic find or restic ls.