Solved

SQL Server 2012 backups

Posted on 2015-01-27
5
89 Views
Last Modified: 2015-01-28
I am running a backup nightly but it saves multiple positions for each night. The size of the bak is now 121 GB. Can I  limit it to 5 last  instances?
 
Here is the script:

BACKUP DATABASE databasename
TO DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\databasename.bak'
 
Thank You
0
Comment
Question by:jem1662
5 Comments
 
LVL 25

Assisted Solution

by:Mohammed Khawaja
Mohammed Khawaja earned 167 total points
ID: 40573921
What I recommend for you to do is add -init to your script and it will overwrite.  If you are backing up the backups each night then you just need the last one.  By any chance if you want to keep just the last five then I suggest you change it to keep the last seven by running a batch file once a week to rename the file to something else.
0
 

Author Comment

by:jem1662
ID: 40573933
Thank You.  I will try it.
0
 
LVL 46

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 166 total points
ID: 40574678
What I recommend for you to do is add -init to your script and it will overwrite
Be careful with this recommendation. If you do that you'll only have the last backup and you can't recover nothing before that day.

What you should do is a complete backup plan, i.e. backing up the databases and move old backup files to a safe place (another media in another location) so you can free space and keep old backups in the case you need them in the future.

Also, why are you having a single file to backup all databases? Recommendation is one file per database.

Please review your backup plan.
0
 
LVL 29

Accepted Solution

by:
Rich Weissler earned 167 total points
ID: 40575044
Concur with Vitor Montalvão.  While considering changing to your backup implementation, I can say that the Maintenance Plans built by the wizard will follow this recommendation.  If the Maintenance Plan capabilities in SQL is not to your liking, you can also look at Ola Hallengren's solution.

Consider also what would happen if the hard disk volumes were to become unavailable.  Are your backups to disk then backed up to tape, or to alternate storage?
0
 

Author Closing Comment

by:jem1662
ID: 40575060
Thank You all for the input.  We do one file per database.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now