Solved

Backups to overwrite, not append

Posted on 2004-03-30
4
501 Views
Last Modified: 2008-03-06
I have SQL Server 2000 running on a Win2K Server platform.

I use the SQL Server Agent > Jobs to schedule daily backups of my databases.
The backups are done to a hard drive on the network.
I have 7 backups, one for each day of the week, so that I can keep the last whole weeks data. Each days backup is done to a different file.

This is the T-SQL I use to run Mondays backup:

backup database myDB
to myDB_mon_backup
with
retaindays = 6


The problem I am having is that when the next Mondays backup runs it APPENDS the backup to the old file, so my backup file gets bigger and bigger every week.

Can you show me the T-SQL that will OVERWRITE the old backup?

Thanks.
0
Comment
Question by:naqayya
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
arbert earned 200 total points
ID: 10713729
add WITH INIT to your backup statement
0
 

Author Comment

by:naqayya
ID: 10713894
Is this the correct syntax:

backup database myDB
to myDB_mon_backup
with
retaindays = 6,
INIT
0
 
LVL 1

Expert Comment

by:FatalErr
ID: 10718943
If you right click on your database and choose "All Tasks", "Maintenance Plan" a wizard will help you set up a plan that will automatically give individual names to the backup files based on the database name and the date of backup.   They are not appended (I think that is the only way it works, i.e. append isn't an option). It's really easy to do and the best way I have found to set up my backups.
0
 

Author Comment

by:naqayya
ID: 10739604
Thanks for your help FatalErr. I would rather stick to the backups that I have already setup for the time being, so arbert's solution is good for me.

Thanks again.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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
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
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

895 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

14 Experts available now in Live!

Get 1:1 Help Now