|
@@ -20,7 +20,7 @@ function backup_aragorn {
|
|
|
# Setup to use 7zip
|
|
|
if (! (Test-Path 'C:\Program Files\7-Zip\7z.exe')) {
|
|
|
Write-Error "Unable to locate 7-zip program file"
|
|
|
- exit 1
|
|
|
+ throw 'Unable to locate 7-zip executable'
|
|
|
}
|
|
|
Set-Alias sz 'C:\Program Files\7-Zip\7z.exe'
|
|
|
|
|
@@ -75,7 +75,7 @@ function backup_aragorn {
|
|
|
}
|
|
|
|
|
|
# Get the age of the backup to make sure we are using the right disk
|
|
|
-function check_disk($diskoverride) {
|
|
|
+function check_disk($diskoverride=$false) {
|
|
|
|
|
|
$backupDisk = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.VolumeName -match "Backup"}
|
|
|
$partialBackup = $false
|
|
@@ -85,7 +85,7 @@ function check_disk($diskoverride) {
|
|
|
if ($last_updated.AddDays(20) -lt (Get-Date)) {
|
|
|
if (!($diskoverride)) {
|
|
|
Write-Host -ForegroundColor DarkRed "This disk was last used less than 3 weeks ago. Override with -diskoverride."
|
|
|
- exit(1)
|
|
|
+ throw 'Unable to proceed'
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -93,7 +93,7 @@ function check_disk($diskoverride) {
|
|
|
# How much free space is there?
|
|
|
if ($backupDisk.FreeSpace / 1gb -lt 20) {
|
|
|
Write-Host -ForegroundColor DarkRed "There is less than 20gb free on the disk."
|
|
|
- exit(1)
|
|
|
+ throw 'Unable to proceed'
|
|
|
}
|
|
|
|
|
|
|