Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iphone-backup

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.

Workflow

  1. Attach the iPhone to WSL with scripts/attach-device.ps1.
  2. Mount the device inside WSL with scripts/mount-device.sh.
  3. Run cmd/iphone-backup against the mounted DCIM directory.

The backup output is organized as output/<year>/<month>/YYYY-MM-DD_HH-MM-SS_<original-name>.

Requirements

  • Go 1.26.2 or newer.
  • usbipd-win on Windows.
  • A WSL distribution with ifuse, idevice_id, idevicepairand fusermount available.
  • A .env file in the repo root with at least HARDWARE_ID for scripts/attach-device.ps1.

Windows to WSL device attach

Use scripts/attach-device.ps1 to bind the iPhone hardware ID to WSL via usbipd-win.

.\scripts\attach-device.ps1

The 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.

Mounting in WSL

After the device is attached, mount it in WSL with scripts/mount-device.sh.

./scripts/mount-device.sh

The 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/DCIM

Running the backup

go run ./cmd/iphone-backup -input /home/maboke/mnt/iphone/DCIM -output ./output -limit 1000

Flags:

  • -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.

What the tool does

  • 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 layout

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.

Project structure

  • 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.

About

iPhone media backup tool for Windows + WSL that mounts the device via usbipd-win and ifuse, then copies DCIM into a date-based archive while skipping files already backed up.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages