rework for large file copy
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
$VMs = @{}
|
||||
|
||||
Import-Module BitsTransfer
|
||||
|
||||
function shutdownHyperV(){
|
||||
$machines = Get-VM
|
||||
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(){
|
||||
|
||||
$d = (Get-Date -format "yyyy-MM-dd").ToString()
|
||||
@@ -91,14 +114,15 @@ function copyFiles(){
|
||||
$out = New-Item -ItemType Directory -Force -Path $Destination
|
||||
|
||||
$Source = "D:\Hyper-V"
|
||||
Write-Host "Copying files from: $source to: $destination"
|
||||
Copy-Item -Path $Source -Destination $Destination -Recurse
|
||||
$Dest = $Destination+"\Hyper-V"
|
||||
copyDir -Source $Source -Destination $Dest
|
||||
|
||||
$Source = "D:\docker-desktop"
|
||||
Write-Host "Copying files from: $source to: $destination"
|
||||
Copy-Item -Path $Source -Destination $Destination -Recurse
|
||||
$Dest = $Destination+"\docker-desktop"
|
||||
copyDir -Source $Source -Destination $Dest
|
||||
}
|
||||
|
||||
|
||||
#Main...
|
||||
Write-Host "Starting Backup script..."
|
||||
$s = Get-Date
|
||||
|
||||
Reference in New Issue
Block a user