Skip to main content

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.

Quick Summary

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

FlagDescription
--target PATH(Required) Where to save the restored files
--include PATTERNOnly restore files matching a pattern (e.g., /etc/nginx/*)
--exclude PATTERNSkip files matching a pattern during restore
--host HOSTNAMEFilter by host when using latest
--tag TAGFilter by tag when using latest
--path PATHFilter by path when using latest
--verifyVerify 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

Methodrestoremount
SpeedFast (bulk transfer)Slower (network latency)
Use CaseLarge-scale recoveryBrowsing for small files
I/OWrites data to diskRead-only virtual view
RequirementsFree disk spaceFUSE support
Success Tip: Dry Run Restore

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

PitfallConsequencePrevention
Wrong Target PathOverwriting active data or restoring to the wrong disk.Always restore to a temporary folder like /tmp/restore first.
Forgetting --includeRestoring 1TB of data when you only needed 1KB.Use specific patterns when you only need a few files.
Permissions MismatchRestored 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.