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:
@@ -150,8 +150,14 @@ function Backup-ExistingConfig {
|
|||||||
$backupDir = Join-Path $env:USERPROFILE ".claude-backup-$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
$backupDir = Join-Path $env:USERPROFILE ".claude-backup-$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||||
|
|
||||||
if (Test-Path $claudeDir) {
|
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
|
Write-ColorOutput "Backup created at: $backupDir" -Type Success
|
||||||
|
} else {
|
||||||
|
Write-ColorOutput "Backup had some issues (continued anyway)." -Type Warning
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-ColorOutput "No existing configuration to backup." -Type Info
|
Write-ColorOutput "No existing configuration to backup." -Type Info
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user