Ctrl K

Restic Restore Test with External Drive

Validate a restic backup by restoring onto a clean external drive. Step by step disk preparation, restore execution, file verification, and safe unplug.

To confirm a backup is properly set and can be restored we will replicate the full restore process in an external drive. This procedure uses an external harddisk conneted via USB as a clean restore target.

Identify the external disk

List all block devices to locate the external drive. It will appear separately from internal NVMe drives, typically as /dev/sda.

lsblk -o NAME,SIZE,MODEL,FSTYPE,MOUNTPOINTS

If the MOUNTPOINTS column shows a path for any partition under /dev/sda, the disk is already mounted. If empty, it is detected but not mounted. Do not continue unless the target disk is clearly identified.

Wipe and prepare the external disk

This destroys everything on the target disk. Unmount first if any partition is currently mounted.

# unmount if mounted
sudo umount ~/mnt/restic-backup 2>/dev/null

# install gptfdisk if not available (Arch)
sudo pacman -S gptfdisk

# wipe and create fresh partition table
sudo wipefs -a /dev/sda
sudo sgdisk --zap-all /dev/sda
sudo parted -s /dev/sda mklabel gpt
sudo parted -s /dev/sda mkpart primary ext4 1MiB 100%

# format
sudo mkfs.ext4 -L restic_backup /dev/sda1

Mount the prepared disk

mkdir -p ~/mnt/restic-backup
sudo mount /dev/sda1 ~/mnt/restic-backup
sudo chown -R $USER:$USER ~/mnt/restic-backup

Verify the mount succeeded and the filesystem is accessible.

lsblk -f /dev/sda
df -h ~/mnt/restic-backup

Set repository path and check snapshots

Point to the existing restic repository on the backup drive. This is the source you are validating, not the external restore target.

export RESTIC_REPO=/run/media/$USER/backupssd/restic-projects
restic -r $RESTIC_REPO snapshots

Run the restore

mkdir -p ~/mnt/restic-backup/restore-test

# restore latest snapshot
restic -r $RESTIC_REPO restore latest --target ~/mnt/restic-backup/restore-test

# or restore a specific snapshot by ID
restic -r $RESTIC_REPO restore 1f52ec5d --target ~/mnt/restic-backup/restore-test

A successful restore prints a summary with file count and total size. If it reports 0 restored files with permission errors, see the troubleshooting section below.

Verify restored files

Restic preserves the full original path inside the restore target. If the backed up path was /home/$USER/projects, the restored content appears under ~/mnt/restic-backup/restore-test/home/$USER/projects.

# list top-level restored directories
ls ~/mnt/restic-backup/restore-test/home/$USER/projects

# compare sizes between original and restored
du -sh ~/projects
du -sh ~/mnt/restic-backup/restore-test/home/$USER/projects

# spot-check specific directories
ls ~/mnt/restic-backup/restore-test/home/$USER/projects/transcribe
ls ~/mnt/restic-backup/restore-test/home/$USER/projects/finlab_quant_code

Safe unplug

Always unmount before disconnecting. Pulling the drive while mounted risks data corruption.

sudo umount ~/mnt/restic-backup

# optional: power off the drive before unplugging
udisksctl power-off -b /dev/sda

# confirm unmounted
mount | grep restic-backup

The ~/mnt/restic-backup directory remains after unmount as an empty folder. This is expected and can be kept for future restores.

Troubleshooting: permission errors on restore

If the restore fails with lchown errors and reports 0 restored files, the ext4 target is owned by root. Fix ownership and retry.

sudo rm -rf ~/mnt/restic-backup/restore-test
sudo mkdir -p ~/mnt/restic-backup/restore-test
sudo chown -R $USER:$USER ~/mnt/restic-backup

# then rerun the restore command

Quick reference

# prepare disk
sudo wipefs -a /dev/sda
sudo sgdisk --zap-all /dev/sda
sudo parted -s /dev/sda mklabel gpt
sudo parted -s /dev/sda mkpart primary ext4 1MiB 100%
sudo mkfs.ext4 -L restic_backup /dev/sda1
mkdir -p ~/mnt/restic-backup
sudo mount /dev/sda1 ~/mnt/restic-backup
sudo chown -R $USER:$USER ~/mnt/restic-backup

# restore
export RESTIC_REPO=/run/media/$USER/backupssd/restic-projects
restic -r "$RESTIC_REPO" snapshots
mkdir -p ~/mnt/restic-backup/restore-test
restic -r "$RESTIC_REPO" restore latest --target ~/mnt/restic-backup/restore-test

# verify
ls ~/mnt/restic-backup/restore-test/home/$USER/projects
du -sh ~/projects
du -sh ~/mnt/restic-backup/restore-test/home/$USER/projects

# unplug
sudo umount ~/mnt/restic-backup

Resources