Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Deleting Old Backup files using T-SQL Script Expand / Collapse
Author
Message
Posted Wednesday, March 24, 2010 2:56 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, May 31, 2010 1:05 PM
Points: 44, Visits: 245
Hi,

Is there a way to delete old backup files without using Xp_cmdshell and scheduling maintenance plans? I tried using xp_delete_file but it works only for native SQL backups and not for litespeed backups.

Any help is appreciated..

Thanks!!!
Post #888752
Posted Wednesday, March 24, 2010 4:20 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 2:56 AM
Points: 2,603, Visits: 2,061
Yes, it is quite possible if you are using sql 2005 or higher.

Create a Maintenance plan and select maintenance cleanup Task. Go to property of the Task and there you will have option to delete specific file extension.

HTH


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #888796
Posted Wednesday, March 24, 2010 4:30 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, May 31, 2010 1:05 PM
Points: 44, Visits: 245
Thanks for the reply but is it possible to delete backups without maintenance plans? I am trying to write a script which takes backup of each database and immediately delete it.. The script should delete the old backup of the database immediately after the new backup is taken... For eg:

declare cursor bkup select name from sysdatabases
open bkup

......
...

......

xp_backup_database @dbname .................

delete old backup files

.........

fetch next from bkup
......


Thanks for your help!!!!


Post #888802
Posted Wednesday, March 24, 2010 6:46 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 2:56 AM
Points: 2,603, Visits: 2,061
You have to create maintenance plan. But it is possible that you do not include any backup step. Also you can have only deleting files Task to your maintenance.

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #888895
Posted Wednesday, March 24, 2010 1:00 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Thursday, July 17, 2014 12:14 PM
Points: 4,386, Visits: 9,501
Litespeed comes with their own xp procedure to delete litespeed based backup files. Look in the documentation for Litespeed and it will show you how to script it out yourself.

The procedure you'll want to use is: xp_slssqlmaint

The parameters will be in a single string and will be something like:

' -MAINTDEL -DELFOLDER "backup folder" -DELEXTENSION "backup extension here"'
-DELUNIT "unit number - eg 60" -DELUNITTYPE "minutes" -DELUSEAGE';

You can delete files based upon days, hours, minutes, etc...


Jeffrey Williams
Problems are opportunites brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs
Post #889276
Posted Wednesday, March 24, 2010 1:17 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, March 18, 2014 12:13 PM
Points: 195, Visits: 1,080
.
Post #889285
Posted Thursday, March 25, 2010 12:14 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, May 31, 2010 1:05 PM
Points: 44, Visits: 245
thanks a lot Jeff!!!! I will try and let you know
Post #889551
Posted Monday, April 5, 2010 7:11 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 5, 2013 11:48 AM
Points: 8, Visits: 111
The suggestions about maintenance plans actually helps me out, good topic, much thanks.
Post #896674
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse