Fix Windows backup: Handle reserved device names (nul, con, prn, etc.)

Windows has reserved device names that cannot be used as file names:
- CON, PRN, AUX, NUL
- COM1-9, LPT1-9

Changed backup function from Copy-Item to Robocopy which properly
handles these reserved names. This fixes the error when backing up
.claude directories that contain files with these names.

Robocopy exit codes:
- 0-7 = Success
- 8+ = Errors

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-22 19:11:06 +00:00
Unverified
parent 68193bbf39
commit fa41790682

View File

@@ -150,8 +150,14 @@ function Backup-ExistingConfig {
$backupDir = Join-Path $env:USERPROFILE ".claude-backup-$(Get-Date -Format 'yyyyMMdd_HHmmss')"
if (Test-Path $claudeDir) {
Copy-Item -Path $claudeDir -Destination $backupDir -Recurse -Force
# Use Robocopy to handle reserved device names (nul, con, prn, etc.)
$robocopyResult = robocopy $claudeDir $backupDir /E /R:0 /W:0 /NFL /NDL /NJH /NJS 2>&1
if ($LASTEXITCODE -lt 8) {
Write-ColorOutput "Backup created at: $backupDir" -Type Success
} else {
Write-ColorOutput "Backup had some issues (continued anyway)." -Type Warning
}
} else {
Write-ColorOutput "No existing configuration to backup." -Type Info
}