- }\r
- }\r
- else {\r
- Write-Host "Directory $backupTargetDiff already exists!"\r
- $errorMessages += "Directory $backupTargetDiff already exists!"\r
- }\r
-}\r
-else {\r
- Write-Host "Full backup"\r
-\r
- if(!(Test-Path $backupTarget)) {\r
- Write-Host "Creating directory $backupTarget"\r
- \r
- try {\r
- New-Item -ItemType directory -Path $backupTarget -ErrorAction Stop\r
- }\r
- catch {\r
- Write-Host "Could not create directory $backupTarget`: $_.Exception.Message"\r
- $errorMessages += "Could not create directory $backupTarget`: $_.Exception.Message"\r
- }\r
- }\r
- \r
- if(!(Test-Path $backupTargetFull)) {\r
- Write-Host "Creating directory $backupTargetFull"\r
- \r
- try {\r
- New-Item -ItemType directory -Path $backupTargetFull -ErrorAction Stop\r
- $doBackup = $True\r
- }\r
- catch {\r
- Write-Host "Could not create directory $backupTargetFull`: $_.Exception.Message"\r
- $errorMessages += "Could not create directory $backupTargetFull`: $_.Exception.Message"\r
- }\r
- }\r
- else {\r
- $doBackup = $True\r
- }\r
- \r
- if($doBackup) {\r
- if($rotateBeforeBackup) {\r
- Rotate-Backup\r
- }\r
- \r
- $dsLogPath = if($dsLogFileToBackup) { "$backupTargetFull\$dsLogFile" } else { $dsLogFile }\r
-\r
- $dsArgs = @($disksToBackup, "--logfile:$dsLogPath", "$backupTargetFull\`$disk.sna") + $dsAdditionalArgs\r
- Write-Host $dsPath ($dsArgs -join " ")\r
- \r
- & $dsPath $dsArgs\r
- \r
- if($LastExitCode -ne 0) {\r
- Write-Host "Drive Snapshot failed to backup! Exit code: $LastExitCode"\r
- $errorMessages += "Drive Snapshot failed to backup! Exit code: $LastExitCode"\r
- }\r
- else {\r
- $success = $True\r
- }\r
- \r
- if($rotateBeforeBackup -eq $False -and $success -eq $True) {\r
- Rotate-Backup\r