This commit is contained in:
2021-11-06 14:03:55 +01:00
parent 0f42fe703a
commit ec22def282

View File

@@ -26,6 +26,7 @@ function Backup-Data($SourcePath,$BackupPath){
$BackupDrive = $BackupPath -replace(':.*','')
$move = $true
foreach($f in $sources){
$Source = $f.FullName
if ($f -eq $sources[$sources.Length-1]){
Write-Host("Copying: $f")
$move = $false
@@ -33,15 +34,16 @@ function Backup-Data($SourcePath,$BackupPath){
Write-Host("Moving: $f")
$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
Write-Host(" Backup-Data-Size: $foldersize (free: $free)")
if ($foldersize -lt $free){
$Destination = $BackupPath+"\"+$f
$Destination = $BackupPath+"\"+$f
Write-Host(" Source-Path: $Source")
Write-Host(" Target-Path: $Destination")
Copy-Dir -Source $SourcePath -Destination $Destination
if ($move){
Remove-Item -Recurse -Force $SourcePath
Remove-Item -Recurse -Force $Source
}
} else {
Write-Host("ERROR: Not enough free space on Backup-Drive!")