Solved

Backups to overwrite, not append

Posted on 2004-03-30
4
503 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Insert to Begin if data exists 2 31
Powershell v3 - SQLCMD 3 26
RAISERROR WITH NOWAIT 2 15
SQL View / Qtry 3 10
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.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

839 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