From b1dff3d1ebf10e88f862420911e76fa165cc64d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Pilgaard=20Gr=C3=B8ndahl?= Date: Fri, 24 Sep 2021 21:57:58 +0200 Subject: [PATCH] the update server script actually respects if you set backupWorld to false now. Also added bool param backupMods --- automation/update-server.ps1 | 49 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/automation/update-server.ps1 b/automation/update-server.ps1 index c500b8e0ca..49b853e7fe 100644 --- a/automation/update-server.ps1 +++ b/automation/update-server.ps1 @@ -12,9 +12,12 @@ param( [bool]$backupWorld = $true, [Parameter(Position = 4)] - [int]$backupsToKeep = 12, + [bool]$backupMods = $true, [Parameter(Position = 5)] + [int]$backupsToKeep = 12, + + [Parameter(Position = 6)] [string]$serverFileFolder = "server_files" ) @@ -55,18 +58,20 @@ function Update-IsAvailable { } function Backup-ModsFolder { - Write-Host - Write-Host "Backing up the mods folder..." -ForegroundColor Cyan - New-Item -ItemType Directory -Path $backupFolder -ErrorAction SilentlyContinue - New-Item -ItemType Directory -Path "$backupFolder/mods" -ErrorAction SilentlyContinue - if (Test-Path $modFolder) { - if ((Get-ChildItem -Path $modFolder | Measure-Object).Count -gt 0) { - Compress-Archive -Path $modFolder "$backupFolder/mods/$(Get-Date -Format "MM.dd.yyyy-HH.mm").zip" - Remove-Item -Path $modFolder -Recurse -ErrorAction SilentlyContinue + if ($backupMods) { + Write-Host + Write-Host "Backing up the mods folder..." -ForegroundColor Cyan + New-Item -ItemType Directory -Path $backupFolder -ErrorAction SilentlyContinue + New-Item -ItemType Directory -Path "$backupFolder/mods" -ErrorAction SilentlyContinue + if (Test-Path $modFolder) { + if ((Get-ChildItem -Path $modFolder | Measure-Object).Count -gt 0) { + Compress-Archive -Path $modFolder "$backupFolder/mods/$(Get-Date -Format "MM.dd.yyyy-HH.mm").zip" + Remove-Item -Path $modFolder -Recurse -ErrorAction SilentlyContinue + } + } + else { + New-Item -ItemType Directory -Path $modFolder -ErrorAction SilentlyContinue } - } - else { - New-Item -ItemType Directory -Path $modFolder -ErrorAction SilentlyContinue } } @@ -90,16 +95,18 @@ function Prune-Backups { } function Backup-WorldFolder { - Write-Host - Write-Host "Backing up the world folder..." -ForegroundColor Cyan - New-Item -ItemType Directory -Path $backupFolder -ErrorAction SilentlyContinue - if (Test-Path $worldFolder) { - if ((Get-ChildItem -Path $worldFolder | Measure-Object).Count -gt 0) { - Compress-Archive -Path $worldFolder "$backupFolder/world-$(Get-Date -Format "MM.dd.yyyy-HH.mm").zip" + if ($backupWorld) { + Write-Host + Write-Host "Backing up the world folder..." -ForegroundColor Cyan + New-Item -ItemType Directory -Path $backupFolder -ErrorAction SilentlyContinue + if (Test-Path $worldFolder) { + if ((Get-ChildItem -Path $worldFolder | Measure-Object).Count -gt 0) { + Compress-Archive -Path $worldFolder "$backupFolder/world-$(Get-Date -Format "MM.dd.yyyy-HH.mm").zip" + } + } + else { + New-Item -ItemType Directory -Path $worldFolder -ErrorAction SilentlyContinue } - } - else { - New-Item -ItemType Directory -Path $worldFolder -ErrorAction SilentlyContinue } }