restic restore
restic restore is the command used to retrieve data from the repository. You can restore an entire snapshot or specific files and directories. You must specify which snapshot to use (via an ID or a keyword like latest) and a target directory where the files will be placed.
Restore is the reason you have backups. Restic makes it fast to pull data out, even if you only need a single file from a large backup.
Basic Syntax
restic restore [snapshotID] --target [destination] [flags]
Snapshot Selectors
# Restore the absolute latest backup
restic restore latest --target /path/to/restore
# Restore a specific snapshot by ID
restic restore d8f3e2a1 --target /path/to/restore
# Restore the latest snapshot for a specific host
restic restore latest --host server-01 --target /path/to/restore
Key Flags
| Flag | Description |
|---|---|
--target PATH | (Required) Where to save the restored files |
--include PATTERN | Only restore files matching a pattern (e.g., /etc/nginx/*) |
--exclude PATTERN | Skip files matching a pattern during restore |
--host HOSTNAME | Filter by host when using latest |
--tag TAG | Filter by tag when using latest |
--path PATH | Filter by path when using latest |
--verify | Verify the restored files against the repository (checksums) |
Practical Examples
1. Full System Recovery
Restore everything from the latest backup to a recovery mount point.
restic restore latest --target /mnt/recovery-disk
2. Surgical File Recovery
Retrieve only a specific configuration file from a snapshot 3 days ago.
restic restore d8f3e2a1 --target /tmp/recovery --include /etc/nginx/nginx.conf
3. Restoring to a Different Host
If Server A crashed, you can restore its data to Server B.
restic restore latest --host server-a --target /home/backups/server-a-data
4. Excluding Large Media
Restore everything except the large video folder.
restic restore latest --target /srv/data --exclude "/srv/data/videos"
restore vs mount
| Method | restore | mount |
|---|---|---|
| Speed | Fast (bulk transfer) | Slower (network latency) |
| Use Case | Large-scale recovery | Browsing for small files |
| I/O | Writes data to disk | Read-only virtual view |
| Requirements | Free disk space | FUSE support |
If you are unsure of the path structure inside the backup, use restic ls first to view the file tree before running a full restore.
Common Pitfalls
| Pitfall | Consequence | Prevention |
|---|---|---|
| Wrong Target Path | Overwriting active data or restoring to the wrong disk. | Always restore to a temporary folder like /tmp/restore first. |
Forgetting --include | Restoring 1TB of data when you only needed 1KB. | Use specific patterns when you only need a few files. |
| Permissions Mismatch | Restored files might have different UIDs if restored on a different server. | Check ownership after the restore is complete. |
Examples with Output
1. Simple Restoration (Latest)
Command:
restic restore latest --target /tmp/recovery
Output:
repository a7b2c9d opened successfully, password is correct
restoring <Snapshot d8f3e2a1 of [/home/user/docs] at 2024-01-15 03:00:00> to /tmp/recovery
Summary: Restored 125 files, 45.21 MiB in 0:03
2. Restoring a Specific Snapshot ID
Command:
restic restore d8f3e2a1 --target /tmp/recovery-old
Output:
repository a7b2c9d opened successfully, password is correct
restoring <Snapshot d8f3e2a1 of [/var/www] at 2023-12-25 12:00:00> to /tmp/recovery-old
Summary: Restored 5400 files, 1.2 GiB in 0:15
3. Surgical Restore (Single File)
Command:
restic restore latest --target /tmp/file-recovery --include /etc/nginx/nginx.conf
Output:
repository a7b2c9d opened successfully, password is correct
restoring <Snapshot f9e2d1c0 of [/etc] at 2024-01-16 03:00:00> to /tmp/file-recovery
Summary: Restored 1 files, 1.4 KiB in 0:01
4. Restore with Exclusions
Command:
restic restore latest --target /tmp/web-recovery --exclude "uploads"
Output:
repository a7b2c9d opened successfully, password is correct
restoring <Snapshot a1b2c3d4 of [/var/www] at 2024-01-16 03:00:00> to /tmp/web-recovery
Summary: Restored 20 files, 5.0 MiB in 0:02
5. Restore with Verification
Command:
restic restore latest --target /tmp/restore-test --verify
Output:
repository a7b2c9d opened successfully, password is correct
restoring <Snapshot d8f3e2a1 of [/home] at 2024-01-15 10:00:00> to /tmp/restore-test
verifying restored files
no errors were found
What's Next?
If you're not sure which snapshot has the file you need, use restic find.