Solved

SQL Server 2012 backups

Posted on 2015-01-27
5
115 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
[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
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 51

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 30

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

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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…

623 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