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
Solved

Query regarding backup maintenance plans

Posted on 2013-01-03
3
372 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
3 Comments
 
LVL 9

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

792 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