# ============================================================================= # migrate-media.ps1 # Migrates user-uploaded media files from host bind-mount (eVibes / early Schon) # into the new Docker-managed named volume (media-data). # # Run this ONCE after upgrading from an eVibes or pre-volume Schon instance. # ============================================================================= Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $HostMedia = Join-Path (Get-Location) "media" Write-Host "Schon - media migration from host bind-mount to named volume" -ForegroundColor Cyan Write-Host "" if (-not (Test-Path $HostMedia)) { Write-Host "No .\media directory found on host. Nothing to migrate." -ForegroundColor Yellow exit 0 } $FileCount = (Get-ChildItem -Path $HostMedia -Recurse -File).Count if ($FileCount -eq 0) { Write-Host "Host .\media directory is empty. Nothing to migrate." -ForegroundColor Yellow exit 0 } Write-Host "Found $FileCount file(s) in $HostMedia" -ForegroundColor White Write-Host "" Write-Host "This will copy them into the Docker named volume 'media-data'." -ForegroundColor White $confirm = Read-Host "Continue? [y/N]" if ($confirm -ne "y" -and $confirm -ne "Y") { Write-Host "Migration cancelled." -ForegroundColor Yellow exit 0 } Write-Host "" Write-Host "Copying files..." -ForegroundColor White $HostMediaUnix = $HostMedia -replace '\\', '/' -replace '^([A-Za-z]):', { "/$(($_.Value[0]).ToString().ToLower())" } docker compose run --rm ` -v "${HostMediaUnix}:/old_media:ro" ` app bash -c @" cp -a /old_media/. /app/media/ COUNT=`$(find /app/media -type f | wc -l) echo "Migration complete: `$COUNT file(s) now in media volume." "@ Write-Host "" Write-Host "Done. You can safely ignore the host .\media directory - it is no longer used." -ForegroundColor Green Write-Host "To remove it: Remove-Item -Recurse -Force .\media" -ForegroundColor Gray