Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql backup policy #1557

Merged
merged 10 commits into from
Oct 3, 2024
Merged

Conversation

bcullman
Copy link
Contributor

Background
In some circumstances the pattern matching was too greedy, resulting in additional non-related backfiles being removed.

With this change, harden the ApplyRetentionPolicy to make it more reliable. additionally update tests to account for files that should not be removed.

Pre-requisites
[NA] Id should be a GUID that is not 00000000-0000-0000-0000-000000000000
NOTE If you are modifying an existing step template, please make sure that you do not modify the Id property (updating the Id will break the Library sync functionality in Octopus).
[NA] Version should be incremented, otherwise the integration with Octopus won't update the step template correctly
[NA] Parameter names should not start with $
[NA] Step template parameter names (the ones declared in the JSON, not the script body) should be prefixed with a namespace so that they are less likely to clash with other user-defined variables in Octopus (see OctopusDeploy/Issues#2126). For example, use an abbreviated name of the step template or the category of the step template).
[NA] LastModifiedBy field must be present, and (optionally) updated with the correct author
[✔] The best practices documented here have been applied
[NA] If a new Category has been created:
[NA] An image with the name {categoryname}.png must be present under the step-templates/logos folder
[NA] The switch in the humanize function in gulpfile.babel.js must have a case statement corresponding to it

Copy link
Contributor

@benPearce1 benPearce1 left a comment

Choose a reason for hiding this comment

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

This looks fine.
Some suggestions in the structure to reduce nesting:

  • Move the $RetentionPolicyCount -eq 0 to the top of the if block and change it to -le 0
  • Remove each of the nested if ($RetentionPolicyCount -gt 0)
  • Move each of the log statements out to a function that includes the if($EnableVerboseOutput) to reduce the noise inside that function.

The overall structure would then read

if ($RetentionPolicyCount -le 0) {
  Write-Host "Retention policy not applied as RetentionPolicyCount is set to 0."
} else if ($Devices -gt 1) {
   ...
} else {
   ...
}

@bcullman
Copy link
Contributor Author

bcullman commented Oct 3, 2024

@benPearce1 - thanks for the feedback. I'll make those adjustment.

@bcullman bcullman marked this pull request as draft October 3, 2024 00:24
@bcullman bcullman marked this pull request as ready for review October 3, 2024 18:38
@bcullman
Copy link
Contributor Author

bcullman commented Oct 3, 2024

@benPearce1 ✔️

Copy link
Contributor

@benPearce1 benPearce1 left a comment

Choose a reason for hiding this comment

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

LGTM

@benPearce1 benPearce1 merged commit ff2ed7b into OctopusDeploy:master Oct 3, 2024
2 checks passed
@bcullman bcullman deleted the fix-sql-backup-policy branch October 23, 2024 18:39
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.

2 participants