Delete the backup files older than X days .

  • Will delete the backup files older than X days delete the backup file first or backup the recent file and delete the older file?

    I have free space of 50 GB and I am setting up a maintainance plan for regular daily backup. My database is of 20 GB and I want to retain upto 2 days backup and delete any file older than 2 days. So my question is for the third day will it first backup the db and delete the older files or delete the older file and backup the db?

  • In a SQL 2005 maintenance plan you can define the removal of old backups as a separate task. If you want to remove your old backup files before creating a new backup define it as the first step. Generally it is advised to create a new backup first before deleting the old one, but if you keep more than one day on disk it shouldn't be a problem.

    Hope this helps

    [font="Verdana"]Markus Bohse[/font]

  • I know it is always better to take a backup first and delete the older file.

    But as I said I have a space constraint so cannot do that. Anyway I got my answer. But the same maintainance plan is there in 2000. Can I know How it works in 2000 whether it will backup first or delete first?

  • In SQL 2000 maintenance plans the backup is taken first and then the old files are dteleted. You cannot change this behaviour within SQL 2000 maintenance plan, you need to write your own script.

    [font="Verdana"]Markus Bohse[/font]

  • Thanks for the solution. I will redesign my maintainance plan.

  • [font="Verdana"]Try the script below

    Backup Script with Retention[/url][/font]

  • Vidhya.. I take the the deletion /retention part of the script relies on this either being called manually or called as part of a job ?

    thanks

    ~simon

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply