Closed DGWright61 closed 2 weeks ago
Looks like you are putting backup type in filename instead of folder. Error message is quite clear. Cleanup parameter need a folder name, put at least backup type and database name in Directory instead of null
Have you been doing any changes to the parameters recently?
Did the errors start when you updated to the 2024-10-27 - version? Which version were you running before?
I can add that the errors are by design.
If the database name is not in the directory path, it can happen that the cleanup for one database is deleting backup files for other databases.
If the backup type is not in the directory path, it can happen that the cleanup for a differential backup is deleting full backup files.
This is because of how xp_delete_file works: xp_delete_file is the extended stored procedure that DatabaseBackup (and the maintenance plans) use to delete backup files. xp_delete_file deletes backup files based on a directory, a file extension, and a modified date.
I have checked and the code has been the same since the @DirectoryStructure parameter was introduced 2018-05-23.
I should add that I am running this in a SQL Agent job. It's been running for two years without fail and no change. However, your second comment does make sense. Perhaps my CleanupTime had not expired until just now thus revealing the issue. Unfortunately, this is an unusual case because the backup files for both databases need to be in the same folder so the vendor can pick them up to move offsite. Guess I'll need to find a different way to accomplish this particular task.
I should add that I am running this in a SQL Agent job. It's been running for two years without fail and no change. However, your second comment does make sense.
Maybe there had been some customization in your old version?
Perhaps my CleanupTime had not expired until just now thus revealing the issue.
This should not affect things.
Unfortunately, this is an unusual case because the backup files for both databases need to be in the same folder so the vendor can pick them up to move offsite. Guess I'll need to find a different way to accomplish this particular task.
The easiest is if you search for the error messages in the code and comment out these checks.
I haven't customized your code. I really don't want to do that. Just use it as is. I'm using it to backup other databases in the same SQL instance. I'll figure out another way to do this particular task.
I have been running this script without fail for about 2 years. I am now getting an error about parameters. (If this isn't actually a bug, please forgive me)
SQL Server version and edition Microsoft SQL Server 2016 (SP2-CU17) (KB5001092) - 13.0.5888.11 (X64) Mar 19 2021 19:41:38 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)
Version of the script 2024-10-27 11:48:54
What command are you executing?
What output are you getting?