rework for large file copy
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
$VMs = @{}
|
$VMs = @{}
|
||||||
|
|
||||||
|
Import-Module BitsTransfer
|
||||||
|
|
||||||
function shutdownHyperV(){
|
function shutdownHyperV(){
|
||||||
$machines = Get-VM
|
$machines = Get-VM
|
||||||
foreach ($m in $machines) {
|
foreach ($m in $machines) {
|
||||||
@@ -84,6 +86,27 @@ function startDocker(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyDir($Source,$Destination){
|
||||||
|
|
||||||
|
Write-Host("Copy Folder: $Source to Folder: $Destination")
|
||||||
|
$files = Get-ChildItem $Source -Recurse
|
||||||
|
foreach ($f in $files){
|
||||||
|
$dest = $f.FullName.Replace($Source,$Destination)
|
||||||
|
if ($f.PSIsContainer){
|
||||||
|
$n = New-Item -ItemType Directory -Force -Path $dest
|
||||||
|
} else {
|
||||||
|
if ($f.Length -gt 10000000){
|
||||||
|
#Start-BitsTransfer -Source $f.FullName -Destination $dest
|
||||||
|
} else {
|
||||||
|
#Copy-Item -Path $f.FullName -Destination $dest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function copyFiles(){
|
function copyFiles(){
|
||||||
|
|
||||||
$d = (Get-Date -format "yyyy-MM-dd").ToString()
|
$d = (Get-Date -format "yyyy-MM-dd").ToString()
|
||||||
@@ -91,14 +114,15 @@ function copyFiles(){
|
|||||||
$out = New-Item -ItemType Directory -Force -Path $Destination
|
$out = New-Item -ItemType Directory -Force -Path $Destination
|
||||||
|
|
||||||
$Source = "D:\Hyper-V"
|
$Source = "D:\Hyper-V"
|
||||||
Write-Host "Copying files from: $source to: $destination"
|
$Dest = $Destination+"\Hyper-V"
|
||||||
Copy-Item -Path $Source -Destination $Destination -Recurse
|
copyDir -Source $Source -Destination $Dest
|
||||||
|
|
||||||
$Source = "D:\docker-desktop"
|
$Source = "D:\docker-desktop"
|
||||||
Write-Host "Copying files from: $source to: $destination"
|
$Dest = $Destination+"\docker-desktop"
|
||||||
Copy-Item -Path $Source -Destination $Destination -Recurse
|
copyDir -Source $Source -Destination $Dest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#Main...
|
#Main...
|
||||||
Write-Host "Starting Backup script..."
|
Write-Host "Starting Backup script..."
|
||||||
$s = Get-Date
|
$s = Get-Date
|
||||||
|
|||||||
Reference in New Issue
Block a user