Files
SkyArtShop/Sky_Art_shop/transfer-to-vm.ps1

45 lines
2.1 KiB
PowerShell
Raw Normal View History

# Transfer files to Ubuntu VM
# Replace VM_IP with your Ubuntu VM's IP address
param(
[string]$VMIp = "192.168.1.100", # Change this to your VM's IP
[string]$VMUser = "username" # Change this to your Ubuntu username
)
Write-Host "🚀 Transferring files to Ubuntu VM at $VMIp" -ForegroundColor Cyan
# Test connection
Write-Host "`n📡 Testing connection..." -ForegroundColor Yellow
$testConnection = Test-NetConnection -ComputerName $VMIp -Port 22 -WarningAction SilentlyContinue
if (-not $testConnection.TcpTestSucceeded) {
Write-Host "❌ Cannot connect to VM on port 22 (SSH)" -ForegroundColor Red
Write-Host "Make sure:" -ForegroundColor Yellow
Write-Host " 1. Ubuntu VM is running" -ForegroundColor Yellow
Write-Host " 2. SSH is installed: sudo apt install openssh-server" -ForegroundColor Yellow
Write-Host " 3. IP address is correct: ip addr show" -ForegroundColor Yellow
exit
}
Write-Host "✅ Connection successful!" -ForegroundColor Green
# Transfer files using SCP (requires SCP client on Windows)
Write-Host "`n📦 Transferring files..." -ForegroundColor Cyan
Write-Host "Transferring project files..." -ForegroundColor Yellow
scp -r "E:\mongodb_backup\skyartshop" "$VMUser@${VMIp}:/home/$VMUser/"
Write-Host "Transferring identity database..." -ForegroundColor Yellow
scp "E:\mongodb_backup\identity.db" "$VMUser@${VMIp}:/home/$VMUser/"
Write-Host "Transferring images..." -ForegroundColor Yellow
scp -r "E:\mongodb_backup\images" "$VMUser@${VMIp}:/home/$VMUser/"
Write-Host "`n✅ Files transferred successfully!" -ForegroundColor Green
Write-Host "`n📋 Next steps on Ubuntu VM:" -ForegroundColor Cyan
Write-Host "ssh $VMUser@$VMIp" -ForegroundColor Yellow
Write-Host "sudo mv ~/skyartshop/* /var/www/SkyArtShop/" -ForegroundColor Yellow
Write-Host "sudo cp ~/identity.db /var/www/SkyArtShop/" -ForegroundColor Yellow
Write-Host "sudo mkdir -p /var/www/SkyArtShop/wwwroot/uploads/images" -ForegroundColor Yellow
Write-Host "sudo cp -r ~/images/* /var/www/SkyArtShop/wwwroot/uploads/images/" -ForegroundColor Yellow