Bugfix
This commit is contained in:
@@ -26,6 +26,7 @@ function Backup-Data($SourcePath,$BackupPath){
|
|||||||
$BackupDrive = $BackupPath -replace(':.*','')
|
$BackupDrive = $BackupPath -replace(':.*','')
|
||||||
$move = $true
|
$move = $true
|
||||||
foreach($f in $sources){
|
foreach($f in $sources){
|
||||||
|
$Source = $f.FullName
|
||||||
if ($f -eq $sources[$sources.Length-1]){
|
if ($f -eq $sources[$sources.Length-1]){
|
||||||
Write-Host("Copying: $f")
|
Write-Host("Copying: $f")
|
||||||
$move = $false
|
$move = $false
|
||||||
@@ -33,15 +34,16 @@ function Backup-Data($SourcePath,$BackupPath){
|
|||||||
Write-Host("Moving: $f")
|
Write-Host("Moving: $f")
|
||||||
$move = $true
|
$move = $true
|
||||||
}
|
}
|
||||||
$foldersize = (Get-ChildItem -path $f.FullName -Recurse | Measure-Object -Property Length -sum).Sum / 1Gb
|
$foldersize = (Get-ChildItem -path $Source -Recurse | Measure-Object -Property Length -sum).Sum / 1Gb
|
||||||
$free = (Get-PSDrive -Name $BackupDrive).Free / 1Gb
|
$free = (Get-PSDrive -Name $BackupDrive).Free / 1Gb
|
||||||
Write-Host(" Backup-Data-Size: $foldersize (free: $free)")
|
Write-Host(" Backup-Data-Size: $foldersize (free: $free)")
|
||||||
if ($foldersize -lt $free){
|
if ($foldersize -lt $free){
|
||||||
$Destination = $BackupPath+"\"+$f
|
$Destination = $BackupPath+"\"+$f
|
||||||
|
Write-Host(" Source-Path: $Source")
|
||||||
Write-Host(" Target-Path: $Destination")
|
Write-Host(" Target-Path: $Destination")
|
||||||
Copy-Dir -Source $SourcePath -Destination $Destination
|
Copy-Dir -Source $SourcePath -Destination $Destination
|
||||||
if ($move){
|
if ($move){
|
||||||
Remove-Item -Recurse -Force $SourcePath
|
Remove-Item -Recurse -Force $Source
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host("ERROR: Not enough free space on Backup-Drive!")
|
Write-Host("ERROR: Not enough free space on Backup-Drive!")
|
||||||
|
|||||||
Reference in New Issue
Block a user