January 11, 2016 at 1:32 pm
Hi
I would like to schedule a SQL Agent job to delete old sql backups from the fileshare. Does anyone have any code to do this?
Thanks
Kathy
January 11, 2016 at 1:54 pm
You might want to create an SSIS package to run a cmd or powershell script that will delete the files or do multiple file system tasks to delete specific files.. etc.. Publish the SSIS package an then create a SQL Server Agent Job to run the SSIS package.
January 11, 2016 at 3:02 pm
Or you can consider switching over to Ola Hallengren's excellent database maintenance scripts, available for free at https://ola.hallengren.com/[/url]. They drive all the backups for you, including the cleanup of old backup after a specified retention period. And they do much more.
Oh, and though I have no personal experience with them, I also hear a lot of good things about Minion Backup (http://minionware.net/backup/[/url]). Also free (a paid "pro" version is available, but I think that the features are the same - you basically only pay for enhanced support).
January 12, 2016 at 11:52 am
plamannkathy (1/11/2016)
HiI would like to schedule a SQL Agent job to delete old sql backups from the fileshare. Does anyone have any code to do this?
Thanks
Kathy
I have this as part of a SQL job, one of the steps for my backups
PushD "\\backupserver\folder\server1\" &&("forfiles.exe" /S /M "*DIFF*.sqb" /d -1 /c "cmd /c del @file") & PopD
This is to delete all DIFFs that are older than 1 day. Test that code though!
I combine that with Ola's code, as I had to create a custom job with separate schedule for big databases. But for most people, Ola's solution is more than enough plus he's a great guy with awesome support, for being a 100% free tool I mean.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply