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

scheduled task Expand / Collapse
Author
Message
Posted Monday, October 19, 2009 5:55 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 13, 2013 1:19 AM
Points: 205, Visits: 499
how can i create a scheduled task to delete some backup files from one folder every day...please can you help me wat command i need to write
Post #804981
Posted Monday, October 19, 2009 6:49 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 18, 2014 3:13 AM
Points: 2,704, Visits: 1,149
How are you doing your backups atm, scheduled job or maintenance plans.

--------------------------------------------------------------------------------------
Recommended Articles on How to help us help you and
solve commonly asked questions

Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden
Managing Transaction Logs by Gail Shaw
How to post Performance problems by Gail Shaw
Help, my database is corrupt. Now what? by Gail Shaw
Post #804997
Posted Monday, October 19, 2009 7:15 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, February 11, 2013 8:27 AM
Points: 1,646, Visits: 1,947
Assuming you have a "BKUP" Directory in Drive K and the backup files are with the extension .bak and you need to delete all files with .bak in that directory.

Create a batch file that deletes all the required files.
Deleting all files with the extension .bak would need a command such as "DEL K:\BKUP\*.BAK".

You need to create the batch file and have it run in a SQL Server Job scheduled daily.



Bru Medishetty

Blog -- LearnSQLWithBru

Join on Facebook Page Facebook.com\LearnSQLWithBru

Twitter -- BruMedishetty
Post #805009
Posted Monday, October 19, 2009 8:17 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 3:11 PM
Points: 31,368, Visits: 15,837
There is a task in the maintenance plans that will do this (maintenance cleanup).







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #805068
Posted Monday, October 19, 2009 8:31 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 13, 2013 1:19 AM
Points: 205, Visits: 499
bruhaspathy (10/19/2009)
Assuming you have a "BKUP" Directory in Drive K and the backup files are with the extension .bak and you need to delete all files with .bak in that directory.

Create a batch file that deletes all the required files.
Deleting all files with the extension .bak would need a command such as "DEL K:\BKUP\*.BAK".

You need to create the batch file and have it run in a SQL Server Job scheduled daily.


i have a folder named BACKUp inside that there are many subfolders with the name of servers. so will the command "DEL K:\BKUP\*.BAK" delete all the .BAK file of subfolders
Post #805085
Posted Monday, October 19, 2009 8:50 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 3:11 PM
Points: 31,368, Visits: 15,837
the name of servers or databases? Are you centralizing backups from multiple servers?

VBScript/Powershell might be the easiest way. you can write a script to delete files older than some date.

Here's a VBScript sample: http://itknowledgeexchange.techtarget.com/system-administration/vbscript-to-delete-files-in-a-directory-older-than-x-days/








Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #805103
Posted Tuesday, October 20, 2009 2:50 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 13, 2013 1:19 AM
Points: 205, Visits: 499
Steve Jones - Editor (10/19/2009)
the name of servers or databases? Are you centralizing backups from multiple servers?

VBScript/Powershell might be the easiest way. you can write a script to delete files older than some date.

Here's a VBScript sample: http://itknowledgeexchange.techtarget.com/system-administration/vbscript-to-delete-files-in-a-directory-older-than-x-days/

Post #805512
Posted Tuesday, October 20, 2009 2:50 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 13, 2013 1:19 AM
Points: 205, Visits: 499
shanila_minnu (10/20/2009)
Steve Jones - Editor (10/19/2009)
the name of servers or databases? Are you centralizing backups from multiple servers?

VBScript/Powershell might be the easiest way. you can write a script to delete files older than some date.

Here's a VBScript sample: http://itknowledgeexchange.techtarget.com/system-administration/vbscript-to-delete-files-in-a-directory-older-than-x-days/



ya we are centralizing all the backups to one server
Post #805515
Posted Tuesday, October 20, 2009 6:55 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 3:11 PM
Points: 31,368, Visits: 15,837
Then I would script something. You can use the Windows Scheduled task to run a VBScript as

cscript.exe myscript.vbs

as the command. You can set up loops to run through all folders, and then files, leaving the last .Bak only.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #805639
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse