Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need a script to backup DB and delete old backups Expand / Collapse
Author
Message
Posted Thursday, October 03, 2013 9:38 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 2:34 AM
Points: 191, Visits: 335
I need a script for SQL Server 2000 which can backup the database as well as delete the backup files older than 2 days.
I know I can do it with Maintenance plans but this is a special requirement.
Can someone help me please
Post #1501256
Posted Thursday, October 03, 2013 9:52 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 2:34 AM
Points: 191, Visits: 335
I managed to modify a script which will take backup with time frame.

--Full backup using datetime file name

DECLARE @devname varchar(256)
DECLARE @DirLocationPre varchar(256)
DECLARE @DatabaseName varchar(256)
SET @DirLocationPre = 'D:\DBName\'
SET @DatabaseName = 'DBName'
SELECT @devname = @DirLocationPre + @DatabaseName + '_' + 'db' + '_' + REPLACE(REPLACE(REPLACE(CONVERT(Varchar(40), GETDATE(), 120),'-',''),':',''), ' ', '') + '.bak';
BACKUP DATABASE @DatabaseName to DISK = @devname
GO

Now, i need a script which can delete backups older than 2 days. Can someone help me please
Post #1501265
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse