Restic Restore Test with External Drive
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
Section titled “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,MOUNTPOINTSIf 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
Section titled “Wipe and prepare the external disk”This destroys everything on the target disk. Unmount first if any partition is currently mounted.
# unmount if mountedsudo umount ~/mnt/restic-backup 2>/dev/null
# install gptfdisk if not available (Arch)sudo pacman -S gptfdisk
# wipe and create fresh partition tablesudo wipefs -a /dev/sdasudo sgdisk --zap-all /dev/sdasudo parted -s /dev/sda mklabel gptsudo parted -s /dev/sda mkpart primary ext4 1MiB 100%
# formatsudo mkfs.ext4 -L restic_backup /dev/sda1Mount the prepared disk
Section titled “Mount the prepared disk”mkdir -p ~/mnt/restic-backupsudo mount /dev/sda1 ~/mnt/restic-backupsudo chown -R $USER:$USER ~/mnt/restic-backupVerify the mount succeeded and the filesystem is accessible.
lsblk -f /dev/sdadf -h ~/mnt/restic-backupSet repository path and check snapshots
Section titled “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-projectsrestic -r $RESTIC_REPO snapshotsRun the restore
Section titled “Run the restore”mkdir -p ~/mnt/restic-backup/restore-test
# restore latest snapshotrestic -r $RESTIC_REPO restore latest --target ~/mnt/restic-backup/restore-test
# or restore a specific snapshot by IDrestic -r $RESTIC_REPO restore 1f52ec5d --target ~/mnt/restic-backup/restore-testA 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
Section titled “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 directoriesls ~/mnt/restic-backup/restore-test/home/$USER/projects
# compare sizes between original and restoreddu -sh ~/projectsdu -sh ~/mnt/restic-backup/restore-test/home/$USER/projects
# spot-check specific directoriesls ~/mnt/restic-backup/restore-test/home/$USER/projects/transcribels ~/mnt/restic-backup/restore-test/home/$USER/projects/finlab_quant_codeSafe unplug
Section titled “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 unpluggingudisksctl power-off -b /dev/sda
# confirm unmountedmount | grep restic-backupThe ~/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
Section titled “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-testsudo mkdir -p ~/mnt/restic-backup/restore-testsudo chown -R $USER:$USER ~/mnt/restic-backup
# then rerun the restore commandQuick reference
Section titled “Quick reference”# prepare disksudo wipefs -a /dev/sdasudo sgdisk --zap-all /dev/sdasudo parted -s /dev/sda mklabel gptsudo parted -s /dev/sda mkpart primary ext4 1MiB 100%sudo mkfs.ext4 -L restic_backup /dev/sda1mkdir -p ~/mnt/restic-backupsudo mount /dev/sda1 ~/mnt/restic-backupsudo chown -R $USER:$USER ~/mnt/restic-backup
# restoreexport RESTIC_REPO=/run/media/$USER/backupssd/restic-projectsrestic -r "$RESTIC_REPO" snapshotsmkdir -p ~/mnt/restic-backup/restore-testrestic -r "$RESTIC_REPO" restore latest --target ~/mnt/restic-backup/restore-test
# verifyls ~/mnt/restic-backup/restore-test/home/$USER/projectsdu -sh ~/projectsdu -sh ~/mnt/restic-backup/restore-test/home/$USER/projects
# unplugsudo umount ~/mnt/restic-backup