Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 High Availability (2005)
 Overwrite Full backup

Author  Topic 

jay1
Starting Member

17 Posts

Posted - 2010-09-07 : 07:11:55
I'm using the following script to perform a full daily backup but I need the previous day Backup to be overwritten but it's not working. What would I need to do to make this happen please?

declare @CheckDate [nvarchar](50), @Title [nvarchar](100)
set @CheckDate = replace(replace(convert(nvarchar(50),getdate(),120),':',''), ' ', '_')
set @Title = N'E:\'Datbasename'_Full_'+@CheckDate+''+'.bak'

BACKUP DATABASE 'Datbasename'
TO DISK = @Title
WITH NOFORMAT,INIT, NAME = N''Datbasename'-Full Database Backup',
SKIP, NOREWIND, NOUNLOAD,STATS = 10;

Thank you

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-09-07 : 08:27:18
you're going to have to write another script to delete old backup files.

it's not overwriting because you're giving it a different name every day (as you should be)
Go to Top of Page

jay1
Starting Member

17 Posts

Posted - 2010-09-07 : 09:17:45
quote:
Originally posted by russell

you're going to have to write another script to delete old backup files.

it's not overwriting because you're giving it a different name every day (as you should be)



I thought the INIT key word is used to overwrite previous backups?
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-09-07 : 09:49:16
it's used to overwrite previous backup sets with the same name

in other words if i name my backup database.bak, then back it up again with init to database.bak, it will overwrite.

but if i name it database_20100906.bak, and tomorrow i name it database_20100907.bak, they aren;t the same and with init will not overwrite database_20100906
Go to Top of Page
   

- Advertisement -