Fatal: unable to open repository [. . .] input/output error

restic version:
restic 0.17.3 compiled with go1.23.3 on darwin/arm64
On MacOS 13.6.3, restic installed via homebrew

I run a brief restic script via MacOS launchd services every hour (the plist is at bottom, if it’s relevant). The script is simple:

/Users/hgv/.local/scripts/backup-restic.sh:

#!/usr/bin/env bash
if [[ -d /Volumes/vqz-restic ]]; then
    restic --password-command="security find-generic-password -a hgv -s restic.vqz-restic -w /Users/hgv/Library/Keychains/login.keychain-db" --verbose -r /Volumes/vqz-restic backup /Users/hgv --exclude=/Users/hgv/Library/CloudStorage/Dropbox/online-only --exclude="/Users/hgv/Library/CloudStorage/Dropbox/Camera Uploads"
    restic --password-command="security find-generic-password -a hgv -s restic.vqz-restic -w /Users/hgv/Library/Keychains/login.keychain-db" --verbose -r /Volumes/vqz-restic forget --keep-hourly 12 --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly unlimited
fi

This will work for a couple of days. But eventually I always receive the following error.

Fatal: unable to open repository at /Volumes/vqz-restic: ReadDir: Readdir: lstat /Volumes/vqz-restic/keys/08b02545cde79ea4b16f385d94d721ed3640a5ce9a70e82c8b4f4048e2f3c901: input/output error

Once I unmount and physically disconnect the drive and then reconnect and remount it, the script runs fine again.

I don’t think this is a restic issue necessarily. Instead, I think it’s something about keeping my external drive attached and regularly backing up to it. I had similar issues with TimeMachine, which prompted me to switch to restic. But maybe someone in the community has an idea. I’ve been able to avoid this error if I shut down the computer every evening; but I’d rather not do that. I’ve tried unmounting the drive after running the script (and then mounting before running it) but that didn’t work.

Any ideas from the community are appreciated.

hgv.restic-bak.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>EnvironmentVariables</key>
	<dict>
		<key>PATH</key>
		<string>/opt/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin</string>
	</dict>
	<key>Label</key>
	<string>hgv.restic-bak</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/bin/fdautil</string>
		<string>exec</string>
		<string>/Users/hgv/.local/scripts/backup-restic.sh</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/tmp/launchd/restic-bak-launchd.log</string>
	<key>StandardOutPath</key>
	<string>/tmp/launchd/restic-bak-launchd.log</string>
	<key>StartCalendarInterval</key>
	<dict>
		<key>Minute</key>
		<integer>0</integer>
	</dict>
</dict>
</plist>

Perhaps consider modifying your script a bit so that it gathers information about what it sees when it runs. Things like mount, ls -la /Volumes/vqz-restic and what not. See if something/figure out what differs when the problem appears.

I think that it must be a clue pointing into problem with your external drive - I think it can be interface, controller or disk firmware.

Then unfortunately due to limited data it must be a bit try different bits approach.

Could you try using another disk, change cables? and/or another USB/TB port? Try to update disk firmware?

You should definitely poke around macOS system logs - there should be a clue there. Though it might be learning steep curve to get some useful info out there.

Do not use exfat etc. but native APFS filesystem.

Update to the latest OS possible. If you have to stay with Ventura then it is 13.7.2 now. Your system seems to be seriously kept out of date - there were 10 Ventura updates since your version.

I had issues with external attached USB drives, mainly due to the external USB hub. I’ve replaced it and the issues went (almost) away. Choose one with an external power supply: don’t rely on the on board USB port!

Thanks all for the feedback.

I’ll add some check points to the script to see what else pops out in the log but I think both @kapitainsky and @radel are correct that the fault lies in my external drive. I’ve tried several different drives (with both time machine and now restic) but they are all USB-powered hard drives. I believe there is some sort of issue with waking up after sleep, which is often when the launchd service fails. I’ll try to troubleshoot more, but maybe I just need a drive with its own power source.

Thanks @kapitainsky for pointing out my MacOS version issue. I’ve updated MacOS to 13.7.2 (I’ve had issues with major version upgrades happening without my permission, so autoupdates were off. I misunderstood security updates to include minor version updates. I’m sticking on Ventura for now for compatibility with another system.).

1 Like

Yeah this is what I thought too. Hope you’ll figure it out though :slight_smile: