Solved

Query regarding backup maintenance plans

Posted on 2013-01-03
3
373 Views
Last Modified: 2016-02-11
I am in the process of creating backup maintenance plans my databases. In the data flow task, I’ve placed a ‘Maintenance Cleanup Task’ that follows ‘Backup Database Task’ .  In the ‘File age’ section, I only see an option of deleting files older than ‘n’ number of hours, days, weeks, months or years. Is there a way to delete files older than ‘n’ number of files?
Any suggestions are appreciated.
Thanks!
0
Comment
Question by:UConn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Expert Comment

by:Matt Bowler
ID: 38741969
No there isn't.

The assumption here is that because backups are being taken on a weekly/daily/hourly... basis then they should be cleaned up as such too. This logic falls over slightly if you take adhoc or out of band backups by manually running the jobs (which is often what you do when you set up the plans).

As a general rule - if you take daily backups and want to keep only 7 files then clean up files older than one week....
0
 
LVL 7

Accepted Solution

by:
armchang earned 500 total points
ID: 38742043
Theoretically, there is a way but I'm thinking it is a pretty daunting task to do. It is only possible by using SQL Server Integration Services (SSIS).

This is my theory: If we can get the backup files in one folder location and loop through it, we can do some sorting on it's creation date and determine what is the oldest date (D1). We could then use that data(D1) to delete files (D2) that are older than the date (D1).

To get a start there is this forum discussing about the script for deleting files from SSIS:
http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/449edab3-ec20-4e37-a257-5e4dfce878df/

A
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 38743635
Using Filesystem task, you can count the files with some predefined name and delete based on that.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question