Skip to content

Update sql-backup-database to check if $BackupDirectory exists before attempting to create it - #1707

Merged
twerthi merged 3 commits into
OctopusDeploy:masterfrom
ghardaway2:update-sql-backup-database
Oct 6, 2026
Merged

twerthi merged 3 commits into
OctopusDeploy:masterfrom
ghardaway2:update-sql-backup-database

Conversation

@ghardaway2

Copy link
Copy Markdown
Contributor

The change introduced in v14 of sql-backup-database does not check if $BackupDirectory exists before it tries to create it. If it does exist, Powershell will throw a ResourceExists error and exit script execution. This change checks if the folder exists and only tries to create it if it does not exist by changing:

New-Item -Path (Split-Path $BackupDirectory) -Name (Split-Path $BackupDirectory -Leaf) -ItemType Directory

to:

$backupDirExists = Test-Path -Path $BackupDirectory
if (-not $backupDirExists) {
New-Item -Path (Split-Path $BackupDirectory) -Name (Split-Path $BackupDirectory -Leaf) -ItemType Directory | Out-Null
}

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Review this PR in Hyponome for a side-by-side diff of the step-template JSON and any embedded scripts.

@CLAassistant

CLAassistant commented Oct 6, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@twerthi twerthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@twerthi
twerthi merged commit b0e9700 into OctopusDeploy:master Oct 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants