Solved

Backups to overwrite, not append

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Full Text Search string 5 33
MS SQL 2014 get SPIDs of users 6 26
Sql query for filter 12 22
SQL JOIN + SUBQUERY? 3 13
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
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.

758 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