Sub topic 8
Browsing and restoring files
This chapter assumes you can use the Linux command line, SSH to the backup host, and create snapshots with restic or archives with Borg. You should also understand file ownership and permissions. Practice restores in a temporary directory before changing live system files.
Find the backup you need
A restic snapshot records a point-in-time view of selected paths. A Borg archive provides the same role, but Borg calls it an archive. First, list available restore points.
restic snapshots
borg list ::The output includes an identifier, timestamp, and usually the hostname. Use a timestamp or ID instead of assuming that latest is correct. A recent snapshot might have completed before an important file was created.
| Tool | Restore point | Browse contents |
|---|---|---|
| restic | Snapshot ID | `restic ls SNAPSHOT_ID` |
| Borg | Archive name | `borg list ::ARCHIVE_NAME` |
You can inspect a restic snapshot without restoring it:
restic ls latest /etc/nginxBorg stores paths without their leading slash. List an archive and filter the output when needed:
borg list '::myserver-2026-11-27T02:00:00'
borg list '::myserver-2026-11-27T02:00:00' | grep 'etc/nginx'Restore into a scratch directory
A scratch directory is a temporary location used for inspection. It prevents a mistaken restore from overwriting current files.
For restic, --target selects the restore root. The original path is recreated below that root:
rm -rf /tmp/restore-nginx
mkdir -p /tmp/restore-nginx
restic restore latest \
--target /tmp/restore-nginx \
--include /etc/nginx
find /tmp/restore-nginx/etc/nginx -maxdepth 2 -type f -printThe --include option limits the restore. You can restore one file with its full path:
restic restore latest \
--target /tmp/restore-one \
--include /etc/ssh/sshd_configFor Borg, change to the destination directory and extract the archive there. The archive path does not begin with /.
mkdir -p /tmp/restore-nginx
cd /tmp/restore-nginx
borg extract \
'::myserver-2026-11-27T02:00:00' \
etc/nginxUse a dry run before extracting unfamiliar paths:
borg extract --dry-run --list \
'::myserver-2026-11-27T02:00:00' \
etc/nginxValidate before replacing live files
Compare restored files with the current system. Check content, ownership, permissions, and symbolic links.
diff -u /etc/nginx/nginx.conf \
/tmp/restore-nginx/etc/nginx/nginx.conf
stat /etc/nginx/nginx.conf \
/tmp/restore-nginx/etc/nginx/nginx.confIf the restored file is correct, copy it deliberately and validate the service configuration before restarting it. A restore may contain old credentials or configuration values, so inspect it before installation.
Exercise
Exercise
You deleted /etc/nginx/nginx.conf and want to inspect the newest restic copy without changing the running server. Which command restores only that file into /tmp/recovery?
Show answer
restic restore latest --target /tmp/recovery --include /etc/nginx/nginx.conf