-
Notifications
You must be signed in to change notification settings - Fork 737
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
CleanupTime not deleted backup files for databases that no longer exist #497
Comments
bruh ffs how hard is it to use a code block stop pinging me |
I agree this would be useful. I understand why it doesn't do it, but initially I also assumed it'd clean up the backups it took, not just the ones for databases that exist now. Otherwise it could be nice to mention in the docs for |
Here's a script I wrote to do this. It deletes old BAK and TRN files from folders where there's no matching database. Disclaimer: It's probably buggy, assumes the default folder structure, has hard-coded values like root directory, directory separator, cleanup time, assumes TRN files for transaction log files, doesn't delete empty folders, ... and probably many other problems, but maybe useful for someone:
|
Description of the issue
I have configured my FULL and DIFFERENTIAL backup jobs to clean up files older that 168 jours, but have noticed that when a database is deleted from SQL Server, the backup files never get removed even after the 168 hours has passed. Files for existing Databases are however being cleaned up approriately.
It would be great if there was a way to cleanup backup files for old databases that were deleted.
SQL Server version and edition
Microsoft SQL Server 2017 (RTM-CU21) (KB4557397) - 14.0.3335.7 (X64)
Version of the script
Version: 2020-01-26 14:06:53
What command are you executing?
EXECUTE [dbo].[DatabaseBackup]
@databases = 'USER_DATABASES',
@Directory = N'I:\SQL_Maintenance\Backups',
@BackupType = 'FULL',
@verify = 'Y',
@Cleanuptime = 168,
@compress = 'Y',
@Checksum = 'Y',
@LogToTable = 'Y'
EXECUTE [dbo].[DatabaseBackup]
@databases = 'USER_DATABASES',
@Directory = N'I:\SQL_Maintenance\Backups',
@BackupType = 'DIFF',
@verify = 'Y',
@Cleanuptime = 168,
@compress = 'Y',
@Checksum = 'Y',
@LogToTable = 'Y'
What output are you getting?
The text was updated successfully, but these errors were encountered: