Backup pipeline for iPhone media exposed to Windows through usbipd-win and mounted inside WSL with ifuse. The tool scans the mounted DCIM tree, copies files into a date-based archive layout, preserves the source modification time on every copied file, and skips files that are already backed up when the destination matches by size.
- Attach the iPhone to WSL with
scripts/attach-device.ps1. - Mount the device inside WSL with
scripts/mount-device.sh. - Run
cmd/iphone-backupagainst the mountedDCIMdirectory.
The backup output is organized as output/<year>/<month>/YYYY-MM-DD_HH-MM-SS_<original-name>.
- Go 1.26.2 or newer.
usbipd-winon Windows.- A WSL distribution with
ifuse,idevice_id,idevicepairandfusermountavailable. - A
.envfile in the repo root with at leastHARDWARE_IDforscripts/attach-device.ps1.
Use scripts/attach-device.ps1 to bind the iPhone hardware ID to WSL via usbipd-win.
.\scripts\attach-device.ps1The script loads environment variables from .env, checks HARDWARE_ID, locates the matching bus ID with usbipd list, and attaches the device with usbipd attach --wsl --auto-attach.
After the device is attached, mount it in WSL with scripts/mount-device.sh.
./scripts/mount-device.shThe script clears any stale mount at ~/mnt/iphone, recreates the mount point, validates that an iPhone is visible through idevice_id -l, pairs the device if needed, and mounts it with ifuse.
The source path for the backup is usually:
~/mnt/iphone/DCIMgo run ./cmd/iphone-backup -input /home/maboke/mnt/iphone/DCIM -output ./output -limit 1000Flags:
-input: mounted iPhone source path.-output: destination directory.-limit: maximum number of files scanned in one run.
If -output is omitted, the tool falls back to a relative default, but that is less explicit than setting the path directly.
- Walks the source tree recursively.
- Uses goroutines and a buffered channel to copy files in parallel.
- Emits progress updates while the backup runs.
- Skips a file only when the destination already exists and the size matches.
- Preserves the original modification time with
os.Chtimes.
File types such as HEIC, MOV, PNG, and other iPhone media variants are copied as-is. Live photo pairs remain separate files because the tool works at the filesystem level.
output/
2018/
08/
2018-08-09_12-34-56_IMG_0001.HEIC
2019/
01/
2019-01-02_08-15-00_IMG_0002.MOV
The summary groups files into Photos, Videos, and Other by extension.
cmd/iphone-backup- CLI entrypoint.internal/device- validates the source path.internal/scanner- streams file paths from the source tree.internal/backup- maps a source file to its destination and decides whether to skip.internal/copier- performs the actual file copy and timestamp preservation.internal/stats- progress counters and the final summary.scripts/attach-device.ps1- Windows to WSL device attach script.scripts/mount-device.sh- WSL mount script.