Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
simflex
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-02-05 : 13:13:49
|
| Greetings experts:We back up our db daily to one of the letter drives of our server.Due to the small size of the server and no money to upgrade the server, I have resorted to deleting older backup copies every 3 days.Is there any scripts that I can automate to delete all but the latest 2 copies of the backup data?Hope this is possible.Thanks |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-05 : 13:27:15
|
| You can use Maintenance plan for it. If not, You can use xp_cmdshell. |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2009-02-05 : 15:30:11
|
There's a few differant methods, but i normally like to use a scheduled batch file that runs after everything is sent to my tapes to remove files older than x days. Let me know if you want me to post a sample, I will need to look for it. Success is 10% Intelligence, 70% Determination, and 22% Stupidity.\_/ _/ _/\_/ _/\_/ _/ _/- 881 |
 |
|
|
simflex
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-02-05 : 16:06:11
|
| hi Vinnie881,Thanks for your post.Yes, a sample would be great.Thanks again. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
simflex
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-02-05 : 18:13:54
|
| Thank you Tara for your kindness.Please an idiot like me to as a followup idiotic question.Our log files are backed up to a folder on our server.How does your script help delete log files on the folder, not db.Or does it delete those log files directly from the db eliminating the need to back it up even though what I just asked doesn't really make sense. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2009-02-05 : 18:24:09
|
| The code just deletes any files, regardless of the file extension, that are past the retention period. It doesn't actaully even do anything with a database. It knows what the path is via the data you input into the table. You could modify the code so that the table isn't required. I used the table approach as I was running it against a lot of different paths that had different retention periods.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
|
|
|
|
|