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 2000 Forums
 SQL Server Administration (2000)
 BackUp Quastions

Author  Topic 

acko
Yak Posting Veteran

52 Posts

Posted - 2004-04-26 : 04:18:17
Hi everyone
I have the folowing situations with my backups.
With Database Maintenance Plan is created backup strategy. Full Backup is performing every day at 1.00 am. And Romove files older than: is checked on 2 days, and it's working fine.

I am interested how can i perform this action with tsql, without using DMPlan.
I tryed this:
BACKUP DATABASE TEST TO DISK 'C:...' WITH INIT, RETAINDAYS = 2

I put this statement into job but it is not working. I tryed after that with (WITH NOINIT) but in that case .bak file grow and files older than 2 days are not deleted.

How can i delete files older then 2 days.
Thanks

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-26 : 08:11:17
Most of us use scripts to do our backups. I name my backup files database_full_yyyymmdd.bak. I also log to a table when the database backups start, end, restores start, end, etc. Doing it this way makes deleting old backups really easy. I just delete the backups where the date is three days old.

Make sense? If you need more help, you can search for backup scripts. Me and Tara have both posted ours on here multiple times. If you need more help though just let us know.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

acko
Yak Posting Veteran

52 Posts

Posted - 2004-04-28 : 02:50:28
Hi derrickleggett
can you send me some of those scripts?
thanks
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-04-28 : 04:09:48
See
http://www.nigelrivett.net/BackupAllDatabases.html

It uses a table to control which databases are backed up and how long to keep them and will deal with any new databases that turn up.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

acko
Yak Posting Veteran

52 Posts

Posted - 2004-04-28 : 05:53:30
thanks
Go to Top of Page
   

- Advertisement -