Showing posts with label files. Show all posts
Showing posts with label files. Show all posts

Thursday, March 29, 2012

backup file being reported as corrupt

I am backing up my databases every night. The system admin has a process running where he copies any new files on the drive to a tape drive for backup.

Twice now he has told me that a backup file was corrupt. In both cases, my jobs and processes are still running clean. DBCC checkdb returns no errors. Where is the best place / tool to check for corruption in tables?

Corruption was occurring in the backup process and was not related to SQL Server itself.

backup file being reported as corrupt

I am backing up my databases every night. The system admin has a process running where he copies any new files on the drive to a tape drive for backup.

Twice now he has told me that a backup file was corrupt. In both cases, my jobs and processes are still running clean. DBCC checkdb returns no errors. Where is the best place / tool to check for corruption in tables?

Corruption was occurring in the backup process and was not related to SQL Server itself.

Backup Failure - Delete old files

I have setup my backup job to delete file older than 12 hours. I want to
keep atleast 2 backup files saved. The backup runs every night.
My backup job fails on alternate days.
The day it fails, it completes just 2 steps 'backup database' and 'verify
database'.
The day is completes sucessfully, it completes 4 steps 'backup database' and
'verify database' and 'delete old backup files' and 'check data and index
linkage'.
It started failing for last few months. The same setting used to work fine
before.
Any kind of help is greatly appreciated.
What is the error message you get at 3rd step?
"helpplease" wrote:

> I have setup my backup job to delete file older than 12 hours. I want to
> keep atleast 2 backup files saved. The backup runs every night.
> My backup job fails on alternate days.
> The day it fails, it completes just 2 steps 'backup database' and 'verify
> database'.
> The day is completes sucessfully, it completes 4 steps 'backup database' and
> 'verify database' and 'delete old backup files' and 'check data and index
> linkage'.
> It started failing for last few months. The same setting used to work fine
> before.
> Any kind of help is greatly appreciated.
|||Does not show the description of error inside the job or the maintenance
plan. The following error message is shown on the Application event log.
SQL Server Scheduled Job 'DB Backup Job for DB Maintenance Plan 'Insite
Maint'' (0xE5E76C0F4E0B7546BB973E5A02710F7F) - Status: Failed - Invoked on:
2006-02-20 21:00:00 - Message: The job failed. The Job was invoked by
Schedule 17 (Schedule 1). The last step to run was step 1 (Step 1).
"bluefish" wrote:
[vbcol=seagreen]
> What is the error message you get at 3rd step?
>
> "helpplease" wrote:
|||Specify a report file for the maint plan and check the report file for the error messages.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"helpplease" <helpplease@.discussions.microsoft.com> wrote in message
news:E2EA51C2-6ED1-4EF6-BA39-FEF7D275245E@.microsoft.com...[vbcol=seagreen]
> Does not show the description of error inside the job or the maintenance
> plan. The following error message is shown on the Application event log.
> SQL Server Scheduled Job 'DB Backup Job for DB Maintenance Plan 'Insite
> Maint'' (0xE5E76C0F4E0B7546BB973E5A02710F7F) - Status: Failed - Invoked on:
> 2006-02-20 21:00:00 - Message: The job failed. The Job was invoked by
> Schedule 17 (Schedule 1). The last step to run was step 1 (Step 1).
>
> "bluefish" wrote:

Backup Failure - Delete old files

I have setup my backup job to delete file older than 12 hours. I want to
keep atleast 2 backup files saved. The backup runs every night.
My backup job fails on alternate days.
The day it fails, it completes just 2 steps 'backup database' and 'verify
database'.
The day is completes sucessfully, it completes 4 steps 'backup database' and
'verify database' and 'delete old backup files' and 'check data and index
linkage'.
It started failing for last few months. The same setting used to work fine
before.
Any kind of help is greatly appreciated.What is the error message you get at 3rd step?
"helpplease" wrote:
> I have setup my backup job to delete file older than 12 hours. I want to
> keep atleast 2 backup files saved. The backup runs every night.
> My backup job fails on alternate days.
> The day it fails, it completes just 2 steps 'backup database' and 'verify
> database'.
> The day is completes sucessfully, it completes 4 steps 'backup database' and
> 'verify database' and 'delete old backup files' and 'check data and index
> linkage'.
> It started failing for last few months. The same setting used to work fine
> before.
> Any kind of help is greatly appreciated.|||Does not show the description of error inside the job or the maintenance
plan. The following error message is shown on the Application event log.
SQL Server Scheduled Job 'DB Backup Job for DB Maintenance Plan 'Insite
Maint'' (0xE5E76C0F4E0B7546BB973E5A02710F7F) - Status: Failed - Invoked on:
2006-02-20 21:00:00 - Message: The job failed. The Job was invoked by
Schedule 17 (Schedule 1). The last step to run was step 1 (Step 1).
"bluefish" wrote:
> What is the error message you get at 3rd step?
>
> "helpplease" wrote:
> > I have setup my backup job to delete file older than 12 hours. I want to
> > keep atleast 2 backup files saved. The backup runs every night.
> > My backup job fails on alternate days.
> >
> > The day it fails, it completes just 2 steps 'backup database' and 'verify
> > database'.
> >
> > The day is completes sucessfully, it completes 4 steps 'backup database' and
> > 'verify database' and 'delete old backup files' and 'check data and index
> > linkage'.
> >
> > It started failing for last few months. The same setting used to work fine
> > before.
> >
> > Any kind of help is greatly appreciated.|||Specify a report file for the maint plan and check the report file for the error messages.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"helpplease" <helpplease@.discussions.microsoft.com> wrote in message
news:E2EA51C2-6ED1-4EF6-BA39-FEF7D275245E@.microsoft.com...
> Does not show the description of error inside the job or the maintenance
> plan. The following error message is shown on the Application event log.
> SQL Server Scheduled Job 'DB Backup Job for DB Maintenance Plan 'Insite
> Maint'' (0xE5E76C0F4E0B7546BB973E5A02710F7F) - Status: Failed - Invoked on:
> 2006-02-20 21:00:00 - Message: The job failed. The Job was invoked by
> Schedule 17 (Schedule 1). The last step to run was step 1 (Step 1).
>
> "bluefish" wrote:
>> What is the error message you get at 3rd step?
>>
>> "helpplease" wrote:
>> > I have setup my backup job to delete file older than 12 hours. I want to
>> > keep atleast 2 backup files saved. The backup runs every night.
>> > My backup job fails on alternate days.
>> >
>> > The day it fails, it completes just 2 steps 'backup database' and 'verify
>> > database'.
>> >
>> > The day is completes sucessfully, it completes 4 steps 'backup database' and
>> > 'verify database' and 'delete old backup files' and 'check data and index
>> > linkage'.
>> >
>> > It started failing for last few months. The same setting used to work fine
>> > before.
>> >
>> > Any kind of help is greatly appreciated.

Backup Failure - Delete old files

I have setup my backup job to delete file older than 12 hours. I want to
keep atleast 2 backup files saved. The backup runs every night.
My backup job fails on alternate days.
The day it fails, it completes just 2 steps 'backup database' and 'verify
database'.
The day is completes sucessfully, it completes 4 steps 'backup database' and
'verify database' and 'delete old backup files' and 'check data and index
linkage'.
It started failing for last few months. The same setting used to work fine
before.
Any kind of help is greatly appreciated.What is the error message you get at 3rd step?
"helpplease" wrote:

> I have setup my backup job to delete file older than 12 hours. I want to
> keep atleast 2 backup files saved. The backup runs every night.
> My backup job fails on alternate days.
> The day it fails, it completes just 2 steps 'backup database' and 'verify
> database'.
> The day is completes sucessfully, it completes 4 steps 'backup database' a
nd
> 'verify database' and 'delete old backup files' and 'check data and index
> linkage'.
> It started failing for last few months. The same setting used to work fin
e
> before.
> Any kind of help is greatly appreciated.|||Does not show the description of error inside the job or the maintenance
plan. The following error message is shown on the Application event log.
SQL Server Scheduled Job 'DB Backup Job for DB Maintenance Plan 'Insite
Maint'' (0xE5E76C0F4E0B7546BB973E5A02710F7F) - Status: Failed - Invoked on:
2006-02-20 21:00:00 - Message: The job failed. The Job was invoked by
Schedule 17 (Schedule 1). The last step to run was step 1 (Step 1).
"bluefish" wrote:
[vbcol=seagreen]
> What is the error message you get at 3rd step?
>
> "helpplease" wrote:
>|||Specify a report file for the maint plan and check the report file for the e
rror messages.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"helpplease" <helpplease@.discussions.microsoft.com> wrote in message
news:E2EA51C2-6ED1-4EF6-BA39-FEF7D275245E@.microsoft.com...[vbcol=seagreen]
> Does not show the description of error inside the job or the maintenance
> plan. The following error message is shown on the Application event log.
> SQL Server Scheduled Job 'DB Backup Job for DB Maintenance Plan 'Insite
> Maint'' (0xE5E76C0F4E0B7546BB973E5A02710F7F) - Status: Failed - Invoked on
:
> 2006-02-20 21:00:00 - Message: The job failed. The Job was invoked by
> Schedule 17 (Schedule 1). The last step to run was step 1 (Step 1).
>
> "bluefish" wrote:
>

Backup fails: "A nonrecoverable I/O error occurred on file"

We have been having a problem with one of our backups:
A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
It's on the same external storage drive as all of our databases yet it's the
only one that errors out, so it appears that the problem is with the .mdf
file, not with the hard disk. And it only errors intermittently...sometimes
the backup succeeds.
We have:
Run dbcc checkdb and receive no errors.
Dropped the database and restored from backup thinking the .mdf file would
be recreated.
We're not sure what to try next. Again, it doesn't seem like a hardware
problem but I can't rule it out either. Please advise.
"nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
news:E0948BFC-C002-4EBF-9E00-B0EAF6A8E850@.microsoft.com...
> We have been having a problem with one of our backups:
> A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft
> SQL
> Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
> It's on the same external storage drive as all of our databases yet it's
> the
> only one that errors out, so it appears that the problem is with the .mdf
> file, not with the hard disk. And it only errors
> intermittently...sometimes
> the backup succeeds.
> We have:
> Run dbcc checkdb and receive no errors.
> Dropped the database and restored from backup thinking the .mdf file would
> be recreated.
> We're not sure what to try next. Again, it doesn't seem like a hardware
> problem but I can't rule it out either. Please advise.
Is this a SAN drive per chance? Or any special SCSI drive that may be doing
something while you do a backup?
Otherwise you may need to open a ticket with MS.
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
|||Hello,
Since the issue only occurs iwht one mdf file, it might be a corruption
issue. Since the issue also occurs with a restore from backup, you may try
the following steps to troubleshoot the issue:
1. Create a new, blank database with whatever name and filename you want
(we may rename it later)
2. Generate the scripts of all tables and create them in the new database;
3. Transfer all data into the new database;
4. Check if the issue occurs with the new database
If the issue does not occur any more, you may want to detach the old
database, and rename the new database to the original name to test.
If the issue persists, you may want to use hardware check tool to confirm
there is no hardware related issue.
To find out the root cause of this issue we may need to analyze memory
dumps, this work has to be done by contacting Microsoft Product Support
Services. Therefore, we probably will not be able to resolve the issue
through the newsgroups. I recommend that you open a Support incident with
Microsoft Product Support Services so that a dedicated Support Professional
can assist with this case. If you need any help in this regard, please let
me know.
For a complete list of Microsoft Product Support Services phone numbers,
please go to the following address on the World Wide Web:
http://support.microsoft.com/directory/overview.asp
If you have any concerns or comments on this, please feel free to let's
know. Thank you.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
|||Yes this a SAN drive at a remote datacenter. The backup runs in the middle
of the night so I don't think the SAN has any heavy lifting going on at the
time the backup runs. We're going to continue to investigate and open a
ticket with MS if appropriate.
"Greg D. Moore (Strider)" wrote:

>
>
> "nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
> news:E0948BFC-C002-4EBF-9E00-B0EAF6A8E850@.microsoft.com...
> Is this a SAN drive per chance? Or any special SCSI drive that may be doing
> something while you do a backup?
> Otherwise you may need to open a ticket with MS.
>
> --
> Greg Moore
> SQL Server DBA Consulting Remote and Onsite available!
> Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
>
>
|||We're going to continue to investigate and open a ticket with MS if
appropriate. Thanks for the response...I'll let you know if I have further
questions.
"Peter Yang [MSFT]" wrote:

> Hello,
> Since the issue only occurs iwht one mdf file, it might be a corruption
> issue. Since the issue also occurs with a restore from backup, you may try
> the following steps to troubleshoot the issue:
> 1. Create a new, blank database with whatever name and filename you want
> (we may rename it later)
> 2. Generate the scripts of all tables and create them in the new database;
> 3. Transfer all data into the new database;
> 4. Check if the issue occurs with the new database
> If the issue does not occur any more, you may want to detach the old
> database, and rename the new database to the original name to test.
> If the issue persists, you may want to use hardware check tool to confirm
> there is no hardware related issue.
> To find out the root cause of this issue we may need to analyze memory
> dumps, this work has to be done by contacting Microsoft Product Support
> Services. Therefore, we probably will not be able to resolve the issue
> through the newsgroups. I recommend that you open a Support incident with
> Microsoft Product Support Services so that a dedicated Support Professional
> can assist with this case. If you need any help in this regard, please let
> me know.
> For a complete list of Microsoft Product Support Services phone numbers,
> please go to the following address on the World Wide Web:
> http://support.microsoft.com/directory/overview.asp
> If you have any concerns or comments on this, please feel free to let's
> know. Thank you.
> Best Regards,
> Peter Yang
> MCSE2000/2003, MCSA, MCDBA
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications
> <http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> <http://msdn.microsoft.com/subscriptions/support/default.aspx>.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
|||"nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
news:B86FFC11-4C68-462B-88B5-3C9B640369DF@.microsoft.com...
> Yes this a SAN drive at a remote datacenter. The backup runs in the
> middle
> of the night so I don't think the SAN has any heavy lifting going on at
> the
> time the backup runs. We're going to continue to investigate and open a
> ticket with MS if appropriate.
Was thinking more perhaps the SAN drive might be doing something like
breaking a mirror during that time to do a backup and then recreating the
mirror or some other function and not properly quiescing the database.
[vbcol=seagreen]
> "Greg D. Moore (Strider)" wrote:
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html

Backup fails: "A nonrecoverable I/O error occurred on file"

We have been having a problem with one of our backups:
A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
It's on the same external storage drive as all of our databases yet it's the
only one that errors out, so it appears that the problem is with the .mdf
file, not with the hard disk. And it only errors intermittently...sometimes
the backup succeeds.
We have:
Run dbcc checkdb and receive no errors.
Dropped the database and restored from backup thinking the .mdf file would
be recreated.
We're not sure what to try next. Again, it doesn't seem like a hardware
problem but I can't rule it out either. Please advise."nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
news:E0948BFC-C002-4EBF-9E00-B0EAF6A8E850@.microsoft.com...
> We have been having a problem with one of our backups:
> A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft
> SQL
> Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
> It's on the same external storage drive as all of our databases yet it's
> the
> only one that errors out, so it appears that the problem is with the .mdf
> file, not with the hard disk. And it only errors
> intermittently...sometimes
> the backup succeeds.
> We have:
> Run dbcc checkdb and receive no errors.
> Dropped the database and restored from backup thinking the .mdf file would
> be recreated.
> We're not sure what to try next. Again, it doesn't seem like a hardware
> problem but I can't rule it out either. Please advise.
Is this a SAN drive per chance? Or any special SCSI drive that may be doing
something while you do a backup?
Otherwise you may need to open a ticket with MS.
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html|||Hello,
Since the issue only occurs iwht one mdf file, it might be a corruption
issue. Since the issue also occurs with a restore from backup, you may try
the following steps to troubleshoot the issue:
1. Create a new, blank database with whatever name and filename you want
(we may rename it later)
2. Generate the scripts of all tables and create them in the new database;
3. Transfer all data into the new database;
4. Check if the issue occurs with the new database
If the issue does not occur any more, you may want to detach the old
database, and rename the new database to the original name to test.
If the issue persists, you may want to use hardware check tool to confirm
there is no hardware related issue.
To find out the root cause of this issue we may need to analyze memory
dumps, this work has to be done by contacting Microsoft Product Support
Services. Therefore, we probably will not be able to resolve the issue
through the newsgroups. I recommend that you open a Support incident with
Microsoft Product Support Services so that a dedicated Support Professional
can assist with this case. If you need any help in this regard, please let
me know.
For a complete list of Microsoft Product Support Services phone numbers,
please go to the following address on the World Wide Web:
http://support.microsoft.com/directory/overview.asp
If you have any concerns or comments on this, please feel free to let's
know. Thank you.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
========================================
==========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications
<http://msdn.microsoft.com/subscript...ps/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscript...rt/default.aspx>.
========================================
==========
This posting is provided "AS IS" with no warranties, and confers no rights.|||Yes this a SAN drive at a remote datacenter. The backup runs in the middle
of the night so I don't think the SAN has any heavy lifting going on at the
time the backup runs. We're going to continue to investigate and open a
ticket with MS if appropriate.
"Greg D. Moore (Strider)" wrote:

>
>
> "nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
> news:E0948BFC-C002-4EBF-9E00-B0EAF6A8E850@.microsoft.com...
> Is this a SAN drive per chance? Or any special SCSI drive that may be doi
ng
> something while you do a backup?
> Otherwise you may need to open a ticket with MS.
>
> --
> Greg Moore
> SQL Server DBA Consulting Remote and Onsite available!
> Email: sql (at) greenms.com [url]http://www.greenms.com/sqlserver.html[/ur
l]
>
>|||We're going to continue to investigate and open a ticket with MS if
appropriate. Thanks for the response...I'll let you know if I have further
questions.
"Peter Yang [MSFT]" wrote:

> Hello,
> Since the issue only occurs iwht one mdf file, it might be a corruption
> issue. Since the issue also occurs with a restore from backup, you may try
> the following steps to troubleshoot the issue:
> 1. Create a new, blank database with whatever name and filename you want
> (we may rename it later)
> 2. Generate the scripts of all tables and create them in the new database;
> 3. Transfer all data into the new database;
> 4. Check if the issue occurs with the new database
> If the issue does not occur any more, you may want to detach the old
> database, and rename the new database to the original name to test.
> If the issue persists, you may want to use hardware check tool to confirm
> there is no hardware related issue.
> To find out the root cause of this issue we may need to analyze memory
> dumps, this work has to be done by contacting Microsoft Product Support
> Services. Therefore, we probably will not be able to resolve the issue
> through the newsgroups. I recommend that you open a Support incident with
> Microsoft Product Support Services so that a dedicated Support Professiona
l
> can assist with this case. If you need any help in this regard, please let
> me know.
> For a complete list of Microsoft Product Support Services phone numbers,
> please go to the following address on the World Wide Web:
> http://support.microsoft.com/directory/overview.asp
> If you have any concerns or comments on this, please feel free to let's
> know. Thank you.
> Best Regards,
> Peter Yang
> MCSE2000/2003, MCSA, MCDBA
> Microsoft Online Community Support
> ========================================
==========
> Get notification to my posts through email? Please refer to
> l]
> ications
> <[url]http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx" target="_blank">http://msdn.microsoft.com/subscript...ps/default.aspx>.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> <http://msdn.microsoft.com/subscript...rt/default.aspx>.
> ========================================
==========
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
>|||"nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
news:B86FFC11-4C68-462B-88B5-3C9B640369DF@.microsoft.com...
> Yes this a SAN drive at a remote datacenter. The backup runs in the
> middle
> of the night so I don't think the SAN has any heavy lifting going on at
> the
> time the backup runs. We're going to continue to investigate and open a
> ticket with MS if appropriate.
Was thinking more perhaps the SAN drive might be doing something like
breaking a mirror during that time to do a backup and then recreating the
mirror or some other function and not properly quiescing the database.
[vbcol=seagreen]
> "Greg D. Moore (Strider)" wrote:
>
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html

Backup fails: "A nonrecoverable I/O error occurred on file"

We have been having a problem with one of our backups:
A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
It's on the same external storage drive as all of our databases yet it's the
only one that errors out, so it appears that the problem is with the .mdf
file, not with the hard disk. And it only errors intermittently...sometimes
the backup succeeds.
We have:
Run dbcc checkdb and receive no errors.
Dropped the database and restored from backup thinking the .mdf file would
be recreated.
We're not sure what to try next. Again, it doesn't seem like a hardware
problem but I can't rule it out either. Please advise."nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
news:E0948BFC-C002-4EBF-9E00-B0EAF6A8E850@.microsoft.com...
> We have been having a problem with one of our backups:
> A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft
> SQL
> Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
> It's on the same external storage drive as all of our databases yet it's
> the
> only one that errors out, so it appears that the problem is with the .mdf
> file, not with the hard disk. And it only errors
> intermittently...sometimes
> the backup succeeds.
> We have:
> Run dbcc checkdb and receive no errors.
> Dropped the database and restored from backup thinking the .mdf file would
> be recreated.
> We're not sure what to try next. Again, it doesn't seem like a hardware
> problem but I can't rule it out either. Please advise.
Is this a SAN drive per chance? Or any special SCSI drive that may be doing
something while you do a backup?
Otherwise you may need to open a ticket with MS.
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html|||Hello,
Since the issue only occurs iwht one mdf file, it might be a corruption
issue. Since the issue also occurs with a restore from backup, you may try
the following steps to troubleshoot the issue:
1. Create a new, blank database with whatever name and filename you want
(we may rename it later)
2. Generate the scripts of all tables and create them in the new database;
3. Transfer all data into the new database;
4. Check if the issue occurs with the new database
If the issue does not occur any more, you may want to detach the old
database, and rename the new database to the original name to test.
If the issue persists, you may want to use hardware check tool to confirm
there is no hardware related issue.
To find out the root cause of this issue we may need to analyze memory
dumps, this work has to be done by contacting Microsoft Product Support
Services. Therefore, we probably will not be able to resolve the issue
through the newsgroups. I recommend that you open a Support incident with
Microsoft Product Support Services so that a dedicated Support Professional
can assist with this case. If you need any help in this regard, please let
me know.
For a complete list of Microsoft Product Support Services phone numbers,
please go to the following address on the World Wide Web:
http://support.microsoft.com/directory/overview.asp
If you have any concerns or comments on this, please feel free to let's
know. Thank you.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Yes this a SAN drive at a remote datacenter. The backup runs in the middle
of the night so I don't think the SAN has any heavy lifting going on at the
time the backup runs. We're going to continue to investigate and open a
ticket with MS if appropriate.
"Greg D. Moore (Strider)" wrote:
>
>
> "nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
> news:E0948BFC-C002-4EBF-9E00-B0EAF6A8E850@.microsoft.com...
> > We have been having a problem with one of our backups:
> >
> > A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft
> > SQL
> > Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
> >
> > It's on the same external storage drive as all of our databases yet it's
> > the
> > only one that errors out, so it appears that the problem is with the .mdf
> > file, not with the hard disk. And it only errors
> > intermittently...sometimes
> > the backup succeeds.
> >
> > We have:
> >
> > Run dbcc checkdb and receive no errors.
> > Dropped the database and restored from backup thinking the .mdf file would
> > be recreated.
> >
> > We're not sure what to try next. Again, it doesn't seem like a hardware
> > problem but I can't rule it out either. Please advise.
> Is this a SAN drive per chance? Or any special SCSI drive that may be doing
> something while you do a backup?
> Otherwise you may need to open a ticket with MS.
>
> --
> Greg Moore
> SQL Server DBA Consulting Remote and Onsite available!
> Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
>
>|||We're going to continue to investigate and open a ticket with MS if
appropriate. Thanks for the response...I'll let you know if I have further
questions.
"Peter Yang [MSFT]" wrote:
> Hello,
> Since the issue only occurs iwht one mdf file, it might be a corruption
> issue. Since the issue also occurs with a restore from backup, you may try
> the following steps to troubleshoot the issue:
> 1. Create a new, blank database with whatever name and filename you want
> (we may rename it later)
> 2. Generate the scripts of all tables and create them in the new database;
> 3. Transfer all data into the new database;
> 4. Check if the issue occurs with the new database
> If the issue does not occur any more, you may want to detach the old
> database, and rename the new database to the original name to test.
> If the issue persists, you may want to use hardware check tool to confirm
> there is no hardware related issue.
> To find out the root cause of this issue we may need to analyze memory
> dumps, this work has to be done by contacting Microsoft Product Support
> Services. Therefore, we probably will not be able to resolve the issue
> through the newsgroups. I recommend that you open a Support incident with
> Microsoft Product Support Services so that a dedicated Support Professional
> can assist with this case. If you need any help in this regard, please let
> me know.
> For a complete list of Microsoft Product Support Services phone numbers,
> please go to the following address on the World Wide Web:
> http://support.microsoft.com/directory/overview.asp
> If you have any concerns or comments on this, please feel free to let's
> know. Thank you.
> Best Regards,
> Peter Yang
> MCSE2000/2003, MCSA, MCDBA
> Microsoft Online Community Support
> ==================================================> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications
> <http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> <http://msdn.microsoft.com/subscriptions/support/default.aspx>.
> ==================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>|||"nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
news:B86FFC11-4C68-462B-88B5-3C9B640369DF@.microsoft.com...
> Yes this a SAN drive at a remote datacenter. The backup runs in the
> middle
> of the night so I don't think the SAN has any heavy lifting going on at
> the
> time the backup runs. We're going to continue to investigate and open a
> ticket with MS if appropriate.
Was thinking more perhaps the SAN drive might be doing something like
breaking a mirror during that time to do a backup and then recreating the
mirror or some other function and not properly quiescing the database.
> "Greg D. Moore (Strider)" wrote:
>>
>>
>> "nexdeveloper" <nexdeveloper@.community.nospam> wrote in message
>> news:E0948BFC-C002-4EBF-9E00-B0EAF6A8E850@.microsoft.com...
>> > We have been having a problem with one of our backups:
>> >
>> > A nonrecoverable I/O error occurred on file "D:\Program Files\Microsoft
>> > SQL
>> > Server\MSSQL.1\MSSQL\Data\SOMEDB_Data.mdf"
>> >
>> > It's on the same external storage drive as all of our databases yet
>> > it's
>> > the
>> > only one that errors out, so it appears that the problem is with the
>> > .mdf
>> > file, not with the hard disk. And it only errors
>> > intermittently...sometimes
>> > the backup succeeds.
>> >
>> > We have:
>> >
>> > Run dbcc checkdb and receive no errors.
>> > Dropped the database and restored from backup thinking the .mdf file
>> > would
>> > be recreated.
>> >
>> > We're not sure what to try next. Again, it doesn't seem like a
>> > hardware
>> > problem but I can't rule it out either. Please advise.
>> Is this a SAN drive per chance? Or any special SCSI drive that may be
>> doing
>> something while you do a backup?
>> Otherwise you may need to open a ticket with MS.
>>
>> --
>> Greg Moore
>> SQL Server DBA Consulting Remote and Onsite available!
>> Email: sql (at) greenms.com
>> http://www.greenms.com/sqlserver.html
>>
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.htmlsql

Tuesday, March 27, 2012

Backup fail on msllockdb & pwe files

We use Arcserve for our backup software. Everynight, we get errors that
msllockdb.mdf, msllockdb_ldf, pwe.mdf, & pwe_log.ldf cannot be accessed
because they are being used by another process. Does anyone know what is
causing this and how to correct it?
--
Thanks!You are obviously not using the SQL Server plugin for Arcserver. It is
trying to copy the files directly and that is always a no no for SQL Server.
You need to invoke the SQL Server backup command thru Arcserves SQL Server
specific extensions.
--
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Saucer Man" <saucerman@.nospam.com> wrote in message
news:4742f3fc$0$27025$cc2e38e6@.news.uslec.net...
> We use Arcserve for our backup software. Everynight, we get errors that
> msllockdb.mdf, msllockdb_ldf, pwe.mdf, & pwe_log.ldf cannot be accessed
> because they are being used by another process. Does anyone know what is
> causing this and how to correct it?
> --
> Thanks!
>|||Thanks. I will look into this.
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:O0dQXa4KIHA.1184@.TK2MSFTNGP04.phx.gbl...
> You are obviously not using the SQL Server plugin for Arcserver. It is
> trying to copy the files directly and that is always a no no for SQL
> Server. You need to invoke the SQL Server backup command thru Arcserves
> SQL Server specific extensions.
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "Saucer Man" <saucerman@.nospam.com> wrote in message
> news:4742f3fc$0$27025$cc2e38e6@.news.uslec.net...
>> We use Arcserve for our backup software. Everynight, we get errors that
>> msllockdb.mdf, msllockdb_ldf, pwe.mdf, & pwe_log.ldf cannot be accessed
>> because they are being used by another process. Does anyone know what is
>> causing this and how to correct it?
>> --
>> Thanks!
>

Thursday, March 22, 2012

Backup didn't contain last 8 hours of data

By some for me unknown reason my backup didn't contain
the last 8 hours of data when I restored them. However
the data was in the detached files that I also copied
directly after I backed up the databases. There where no
user except me while performing this operation.
Anyone had problems like this? I thought that a backup
should write all data from the DB's to the devices.
(Recovery model simple and no pending transaction on the
DB's.)
//LEBAre you sure that restore the correct backup? Perhaps you didn't specify NOINIT for the backup and
when restore didn't specify the FILE parameter -> restored an earlier backup.
I have never seen or heard about SQL Server not including the committed transactions in a database
backup. Nor can I see how that can happen architecturally.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"LEB" <lars-erik.blom@.tuesday.se> wrote in message news:09b701c36dfb$496e7360$a301280a@.phx.gbl...
> By some for me unknown reason my backup didn't contain
> the last 8 hours of data when I restored them. However
> the data was in the detached files that I also copied
> directly after I backed up the databases. There where no
> user except me while performing this operation.
> Anyone had problems like this? I thought that a backup
> should write all data from the DB's to the devices.
> (Recovery model simple and no pending transaction on the
> DB's.)
> //LEB|||Neither does me. Since I can see that the DB device is
created at the time when I did the backup I'm sure that
the file is the proper one. I scratched the previous to
be sure. I also specified different file locations, new
since I rebuild the server. As seen from a technical
standpoint there is not a failure running this. The
backup and restore runs smoothly without errors. I've
never been this confused regarding backup/restore before.
Suggestions?
//LEB
>--Original Message--
>Are you sure that restore the correct backup? Perhaps
you didn't specify NOINIT for the backup and
>when restore didn't specify the FILE parameter ->
restored an earlier backup.
>I have never seen or heard about SQL Server not
including the committed transactions in a database
>backup. Nor can I see how that can happen
architecturally.
>--
>Tibor Karaszi, SQL Server MVP
>Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
>"LEB" <lars-erik.blom@.tuesday.se> wrote in message
news:09b701c36dfb$496e7360$a301280a@.phx.gbl...
>> By some for me unknown reason my backup didn't contain
>> the last 8 hours of data when I restored them. However
>> the data was in the detached files that I also copied
>> directly after I backed up the databases. There where
no
>> user except me while performing this operation.
>> Anyone had problems like this? I thought that a backup
>> should write all data from the DB's to the devices.
>> (Recovery model simple and no pending transaction on
the
>> DB's.)
>> //LEB
>
>.
>|||The only last thing I can think of is RESTORE HEADERONLY to be 100% certain...
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"LEB" <lars-erik.blom@.tuesday.se> wrote in message news:037c01c36e19$96b70380$a001280a@.phx.gbl...
> Neither does me. Since I can see that the DB device is
> created at the time when I did the backup I'm sure that
> the file is the proper one. I scratched the previous to
> be sure. I also specified different file locations, new
> since I rebuild the server. As seen from a technical
> standpoint there is not a failure running this. The
> backup and restore runs smoothly without errors. I've
> never been this confused regarding backup/restore before.
> Suggestions?
> //LEB
> >--Original Message--
> >Are you sure that restore the correct backup? Perhaps
> you didn't specify NOINIT for the backup and
> >when restore didn't specify the FILE parameter ->
> restored an earlier backup.
> >I have never seen or heard about SQL Server not
> including the committed transactions in a database
> >backup. Nor can I see how that can happen
> architecturally.
> >
> >--
> >Tibor Karaszi, SQL Server MVP
> >Archive at: http://groups.google.com/groups?oi=djq&as
> ugroup=microsoft.public.sqlserver
> >
> >
> >"LEB" <lars-erik.blom@.tuesday.se> wrote in message
> news:09b701c36dfb$496e7360$a301280a@.phx.gbl...
> >> By some for me unknown reason my backup didn't contain
> >> the last 8 hours of data when I restored them. However
> >> the data was in the detached files that I also copied
> >> directly after I backed up the databases. There where
> no
> >> user except me while performing this operation.
> >> Anyone had problems like this? I thought that a backup
> >> should write all data from the DB's to the devices.
> >> (Recovery model simple and no pending transaction on
> the
> >> DB's.)
> >>
> >> //LEB
> >
> >
> >.
> >

Tuesday, March 20, 2012

Backup Dependent file remove

In SQL Server 2000, when you setup "Delete files older than 1 day" option, it
would not delete files unless the backup completes successfully. If the
backup fails for some reason, you still have the previous backup.
How can this be accomplished in SQL Server 2005 ? Is SSIS Package is the
only way to do it ?
Thanks.
Hi
If you look a Maintenance Plans then the maintenance cleanup task can be set
up to remove files older than a given age from a given directory. This can be
dependent on a the successes of a backup database task, although this would
leave files until the backup problem is fixed and you could end up with weeks
of files from failed backups. If you are going to use maintenance tasks then
there was some issues with upgrading in SP2 so starting on SP2 will remove
any issues with upgrading.
John
"DXC" wrote:

> In SQL Server 2000, when you setup "Delete files older than 1 day" option, it
> would not delete files unless the backup completes successfully. If the
> backup fails for some reason, you still have the previous backup.
> How can this be accomplished in SQL Server 2005 ? Is SSIS Package is the
> only way to do it ?
> Thanks.

Backup Dependent file remove

In SQL Server 2000, when you setup "Delete files older than 1 day" option, it
would not delete files unless the backup completes successfully. If the
backup fails for some reason, you still have the previous backup.
How can this be accomplished in SQL Server 2005 ? Is SSIS Package is the
only way to do it ?
Thanks.Hi
If you look a Maintenance Plans then the maintenance cleanup task can be set
up to remove files older than a given age from a given directory. This can be
dependent on a the successes of a backup database task, although this would
leave files until the backup problem is fixed and you could end up with weeks
of files from failed backups. If you are going to use maintenance tasks then
there was some issues with upgrading in SP2 so starting on SP2 will remove
any issues with upgrading.
John
"DXC" wrote:
> In SQL Server 2000, when you setup "Delete files older than 1 day" option, it
> would not delete files unless the backup completes successfully. If the
> backup fails for some reason, you still have the previous backup.
> How can this be accomplished in SQL Server 2005 ? Is SSIS Package is the
> only way to do it ?
> Thanks.

Backup db files

I am currently using Veritas Netbackup to backup the filesystem on my SQL
server.
Currently, a whole host of .mdf and .ldf files in the <\Program
Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the backup
software because they are in use by another process.
Is there any way to perform a flatfile backup of MSSQL database without
using any software agents? Or must the db be offlined each time in order to
free up those .mdf/.ldf files to be backed up?
Thanks!
"Merc76" <Merc76@.discussions.microsoft.com> wrote in message
news:B01DF591-88C1-4C33-854C-8E151E180018@.microsoft.com...
>I am currently using Veritas Netbackup to backup the filesystem on my SQL
> server.
> Currently, a whole host of .mdf and .ldf files in the <\Program
> Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the
> backup
> software because they are in use by another process.
> Is there any way to perform a flatfile backup of MSSQL database without
> using any software agents? Or must the db be offlined each time in order
> to
> free up those .mdf/.ldf files to be backed up?
> Thanks!
You need to use SQL Server's own native backups to backup the database while
its online. That's something you should definitely do anyway because you
have many more options to control just how the files get backed up and
restored. Read the backup topics in SQL Server Books Online.
Veritas has an agent module that allows you to manage native SQL Server
backups through their software.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
|||Hi
You cannot copy files while a database is in use, however you will be able
to issue BACKUP DATABASE command
"Merc76" <Merc76@.discussions.microsoft.com> wrote in message
news:B01DF591-88C1-4C33-854C-8E151E180018@.microsoft.com...
>I am currently using Veritas Netbackup to backup the filesystem on my SQL
> server.
> Currently, a whole host of .mdf and .ldf files in the <\Program
> Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the
> backup
> software because they are in use by another process.
> Is there any way to perform a flatfile backup of MSSQL database without
> using any software agents? Or must the db be offlined each time in order
> to
> free up those .mdf/.ldf files to be backed up?
> Thanks!

Backup db files

I am currently using Veritas Netbackup to backup the filesystem on my SQL
server.
Currently, a whole host of .mdf and .ldf files in the <\Program
Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the backup
software because they are in use by another process.
Is there any way to perform a flatfile backup of MSSQL database without
using any software agents? Or must the db be offlined each time in order to
free up those .mdf/.ldf files to be backed up?
Thanks!"Merc76" <Merc76@.discussions.microsoft.com> wrote in message
news:B01DF591-88C1-4C33-854C-8E151E180018@.microsoft.com...
>I am currently using Veritas Netbackup to backup the filesystem on my SQL
> server.
> Currently, a whole host of .mdf and .ldf files in the <\Program
> Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the
> backup
> software because they are in use by another process.
> Is there any way to perform a flatfile backup of MSSQL database without
> using any software agents? Or must the db be offlined each time in order
> to
> free up those .mdf/.ldf files to be backed up?
> Thanks!
You need to use SQL Server's own native backups to backup the database while
its online. That's something you should definitely do anyway because you
have many more options to control just how the files get backed up and
restored. Read the backup topics in SQL Server Books Online.
Veritas has an agent module that allows you to manage native SQL Server
backups through their software.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Hi
You cannot copy files while a database is in use, however you will be able
to issue BACKUP DATABASE command
"Merc76" <Merc76@.discussions.microsoft.com> wrote in message
news:B01DF591-88C1-4C33-854C-8E151E180018@.microsoft.com...
>I am currently using Veritas Netbackup to backup the filesystem on my SQL
> server.
> Currently, a whole host of .mdf and .ldf files in the <\Program
> Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the
> backup
> software because they are in use by another process.
> Is there any way to perform a flatfile backup of MSSQL database without
> using any software agents? Or must the db be offlined each time in order
> to
> free up those .mdf/.ldf files to be backed up?
> Thanks!

Backup db files

I am currently using Veritas Netbackup to backup the filesystem on my SQL
server.
Currently, a whole host of .mdf and .ldf files in the <\Program
Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the backup
software because they are in use by another process.
Is there any way to perform a flatfile backup of MSSQL database without
using any software agents? Or must the db be offlined each time in order to
free up those .mdf/.ldf files to be backed up?
Thanks!"Merc76" <Merc76@.discussions.microsoft.com> wrote in message
news:B01DF591-88C1-4C33-854C-8E151E180018@.microsoft.com...
>I am currently using Veritas Netbackup to backup the filesystem on my SQL
> server.
> Currently, a whole host of .mdf and .ldf files in the <\Program
> Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the
> backup
> software because they are in use by another process.
> Is there any way to perform a flatfile backup of MSSQL database without
> using any software agents? Or must the db be offlined each time in order
> to
> free up those .mdf/.ldf files to be backed up?
> Thanks!
You need to use SQL Server's own native backups to backup the database while
its online. That's something you should definitely do anyway because you
have many more options to control just how the files get backed up and
restored. Read the backup topics in SQL Server Books Online.
Veritas has an agent module that allows you to manage native SQL Server
backups through their software.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Hi
You cannot copy files while a database is in use, however you will be able
to issue BACKUP DATABASE command
"Merc76" <Merc76@.discussions.microsoft.com> wrote in message
news:B01DF591-88C1-4C33-854C-8E151E180018@.microsoft.com...
>I am currently using Veritas Netbackup to backup the filesystem on my SQL
> server.
> Currently, a whole host of .mdf and .ldf files in the <\Program
> Files\Microsoft SQL Server\MSSQL\Data> directory are skipped by the
> backup
> software because they are in use by another process.
> Is there any way to perform a flatfile backup of MSSQL database without
> using any software agents? Or must the db be offlined each time in order
> to
> free up those .mdf/.ldf files to be backed up?
> Thanks!

Back-up DB but keep the files for 3 days?

Hi
I have created a job to backup all our database. It works fine and creates .bak files in default folder. I have scheduled the task to run every 4 hours.

My question is how can i modify or program this backup plan to keep the backup files for only last 3 days and delete older backup files?

Mits

That's simple. I assume you are using SQL Server 2000.
If so, in Enterprise Manager, Expand Management node, select Database Maintenance plans.
Right click the maintenance plan and select properties.
Go to the complete backup tab.
Change the "Remove files older than" option to read 3 days and click ok.

Hope that Helps.

|||

A few questions for you to think about if you haven't already:

Are the backups stored on a different physical drive than the databases? If not then they absolutely should be.|||

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.

|||

Matt Fraser wrote:

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.


Matt,

I discovered this issue as well with SQL 2005, and I am perplexed as to why we have a way to back up databases but no way to manage the retention of old backups which can cause our disks to fill up. As a workaround I found this script on the web and use it to delete backup files older than "x" days, and it has worked flawlessly from the first time I started using it.

There are a few different ways to implement this workaround, but I have found the easiest way to is to copy the code below into a Notepad and save it as a .vbs file in the root of your backup drive, you might name the file something like DeleteOldBackups.vbs. This way you would simply create a Scheduled Task that points to this file and set the task to run either before or after all of your backups complete.

Make sure you set the directory paths and number of days to meet your needs.


Option Explicit
on error resume next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld

'Delete database backup files older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\databackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database backup files are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Delete database log file backups older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\logfilebackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database log file backups are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

This has worked great for me, hopefully it will be useful to you and others as well.

|||Thank you everyone for you responses and i like the idea of script and i honestly agree with Matt Fraser.

I am using SQL Server 2005 Enterprise Edition.

I have had it working on SQL Server 2000 using a batch file using following command and this batch file was scheduled to run on sepecific time of the day. This will backup DB and Log files.

SQLMAINT -D DBName -BkUpDB E:\SQLBKUP -BkUpMedia DISK -DelBkUps 3days -VrfyBackup

The backup is taken on a shared Drive on the DB Server which will be backed up in the overall daily backup plan on tape. So everyday on tape, we will have the backup of last 3 days and we dont have to use hard disk space.

Regarding disaster recovery - we literally cant have any downtime from monday to saturday, but, couple of hours on Sunday could be arranged. Backup time is about 10-15 mins.

Yes I regularly restore the backups to check the validity.

I am quiet sure that this batch file will work for SQL Server 2005, but i not particularly keen on using batch file(and if i have to, i will use it). I want to do it through Maintenance Plan.

Mits

|||

I also use script to achieve this at my customers (WMI/VB Script). It's much more flexible and you can code it to do what you want. I've done a few custom versions, if, for example, they want to keep N number of fulls, and only a certain number of days worth of transaction logs, etc.

It works very well, but as you hint at Mits, it is outside the control of SQL Server.

|||

I did some digging and I found out that there is in fact a way to delete old backup files within the SQL management studio. I was told this functionality was going to be added with SP1 and apparently it was, just not where I expected to find it. I haven't had a chance to test it very much so I'm going to continue running my VB Script, but it is there.

Basically there are two ways to create backup jobs for your databases from within the SQL management studio Maintenence Plan area, manually or by using the wizard. If you choose to create your backup plans manually you will see the functionality to delete old backups right away, but here is how I found it because I always like to use the wizard instead.

In the SQL management studio under maintenence plans, right click maintenence plans and select the wizard. Follow the wizard all the way through to create your backup plan, you will not see any option to delete backup files older than "x" days, at the end save your backup plan.

Once your backup plan is visible under maintenence plans, right click it, and click on modify, this will open your backup plan in what appears to be a development environment window and you will see several boxes connected to each other with either green or blue arrows. Look down in the lower left hand corner and you will see a toolbox with about eight different components in it.

Select the component called Maintenence Cleanup History and drag it onto the page with your other boxes. Right click this new box and click edit, when it opens up you will see options to delete backup files older than x days. You can configure it, and then you will need to connect it to the other boxes and save the plan and then run it to test it. I tried it a couple of times and couldn't get it to work so I will have to keep testing it.

The ability to delete old backup files does exit, just not where I thought I would find it.

|||thank you very much andy
I try adding cleanup history step and see if i can get it working.

Mits
|||

Well done, Andy. It seems that SP1 did in fact add this functionality, but the Wizard hasn't been updated yet to include it. So, the key is to add the step for "Maintenance Cleanup Task," recognizing that it's different from "History Cleanup Task" (which is included in the Wizard).

I've added it to my maintenance plan, and in about a week's time I should know if it's working properly.

|||

This appears to work, but I won't be able to tell until tonight since Microsoft has removed the ability to delete files older than x hours. Only days, weeks, months, and years. I always used hours because of variations in backup duration. If a backup had the time of 8:01 one night and 8:00 the next, I would end up with both on the drive if I picked the 1 day option. I always used 23 hours to avoid the drive filling up. It appears that option is gone. Grrrrr! It is annoying to have a feature that you use and rely on only to have it removed.

Microsoft, please add back the hours option in a service pack.

|||

I think the frustration expressed in this thread is entirely justified and I'll ensure that the tools team here sees this.

As added weight, please go to connect.microsoft.com and give this feedback - this will open issues directly in our bug database and you will get feedback from the relevant teams.

Thanks

|||

Thanks for the suggestion! I didn't know about that site. I see a closed item where the response was that "hours" would come back as a duration in SP2. I voted for that and the open item about the same issue.

I also authored an item to make the cleanup task available through the wizard as it was in SQL2000.

Thanks for taking time to listen to our concerns and point me to the right forum for airing them. Your responsiveness does your employer proud.

|||how can I set the schedule of backup as follows using Maintenance Job.

I want to run the backup plan ever 285 mins or 4.75 hours starting at 8.15 in the morning and finishing at 9.15 at night.

I have tried but it wont let me put anything more then 60 mins or 4.75 hours.

Mits
|||

In sql2005 the retention period comes as common sql server setting.when check properties of sql server in database setting you have option to set retention period

Back-up DB but keep the files for 3 days?

Hi
I have created a job to backup all our database. It works fine and creates .bak files in default folder. I have scheduled the task to run every 4 hours.

My question is how can i modify or program this backup plan to keep the backup files for only last 3 days and delete older backup files?

Mits

That's simple. I assume you are using SQL Server 2000.
If so, in Enterprise Manager, Expand Management node, select Database Maintenance plans.
Right click the maintenance plan and select properties.
Go to the complete backup tab.
Change the "Remove files older than" option to read 3 days and click ok.

Hope that Helps.

|||

A few questions for you to think about if you haven't already:

Are the backups stored on a different physical drive than the databases? If not then they absolutely should be.|||

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.

|||

Matt Fraser wrote:

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.


Matt,

I discovered this issue as well with SQL 2005, and I am perplexed as to why we have a way to back up databases but no way to manage the retention of old backups which can cause our disks to fill up. As a workaround I found this script on the web and use it to delete backup files older than "x" days, and it has worked flawlessly from the first time I started using it.

There are a few different ways to implement this workaround, but I have found the easiest way to is to copy the code below into a Notepad and save it as a .vbs file in the root of your backup drive, you might name the file something like DeleteOldBackups.vbs. This way you would simply create a Scheduled Task that points to this file and set the task to run either before or after all of your backups complete.

Make sure you set the directory paths and number of days to meet your needs.


Option Explicit
on error resume next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld

'Delete database backup files older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\databackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database backup files are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Delete database log file backups older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\logfilebackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database log file backups are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

This has worked great for me, hopefully it will be useful to you and others as well.

|||Thank you everyone for you responses and i like the idea of script and i honestly agree with Matt Fraser.

I am using SQL Server 2005 Enterprise Edition.

I have had it working on SQL Server 2000 using a batch file using following command and this batch file was scheduled to run on sepecific time of the day. This will backup DB and Log files.

SQLMAINT -D DBName -BkUpDB E:\SQLBKUP -BkUpMedia DISK -DelBkUps 3days -VrfyBackup

The backup is taken on a shared Drive on the DB Server which will be backed up in the overall daily backup plan on tape. So everyday on tape, we will have the backup of last 3 days and we dont have to use hard disk space.

Regarding disaster recovery - we literally cant have any downtime from monday to saturday, but, couple of hours on Sunday could be arranged. Backup time is about 10-15 mins.

Yes I regularly restore the backups to check the validity.

I am quiet sure that this batch file will work for SQL Server 2005, but i not particularly keen on using batch file(and if i have to, i will use it). I want to do it through Maintenance Plan.

Mits

|||

I also use script to achieve this at my customers (WMI/VB Script). It's much more flexible and you can code it to do what you want. I've done a few custom versions, if, for example, they want to keep N number of fulls, and only a certain number of days worth of transaction logs, etc.

It works very well, but as you hint at Mits, it is outside the control of SQL Server.

|||

I did some digging and I found out that there is in fact a way to delete old backup files within the SQL management studio. I was told this functionality was going to be added with SP1 and apparently it was, just not where I expected to find it. I haven't had a chance to test it very much so I'm going to continue running my VB Script, but it is there.

Basically there are two ways to create backup jobs for your databases from within the SQL management studio Maintenence Plan area, manually or by using the wizard. If you choose to create your backup plans manually you will see the functionality to delete old backups right away, but here is how I found it because I always like to use the wizard instead.

In the SQL management studio under maintenence plans, right click maintenence plans and select the wizard. Follow the wizard all the way through to create your backup plan, you will not see any option to delete backup files older than "x" days, at the end save your backup plan.

Once your backup plan is visible under maintenence plans, right click it, and click on modify, this will open your backup plan in what appears to be a development environment window and you will see several boxes connected to each other with either green or blue arrows. Look down in the lower left hand corner and you will see a toolbox with about eight different components in it.

Select the component called Maintenence Cleanup History and drag it onto the page with your other boxes. Right click this new box and click edit, when it opens up you will see options to delete backup files older than x days. You can configure it, and then you will need to connect it to the other boxes and save the plan and then run it to test it. I tried it a couple of times and couldn't get it to work so I will have to keep testing it.

The ability to delete old backup files does exit, just not where I thought I would find it.

|||thank you very much andy
I try adding cleanup history step and see if i can get it working.

Mits
|||

Well done, Andy. It seems that SP1 did in fact add this functionality, but the Wizard hasn't been updated yet to include it. So, the key is to add the step for "Maintenance Cleanup Task," recognizing that it's different from "History Cleanup Task" (which is included in the Wizard).

I've added it to my maintenance plan, and in about a week's time I should know if it's working properly.

|||

This appears to work, but I won't be able to tell until tonight since Microsoft has removed the ability to delete files older than x hours. Only days, weeks, months, and years. I always used hours because of variations in backup duration. If a backup had the time of 8:01 one night and 8:00 the next, I would end up with both on the drive if I picked the 1 day option. I always used 23 hours to avoid the drive filling up. It appears that option is gone. Grrrrr! It is annoying to have a feature that you use and rely on only to have it removed.

Microsoft, please add back the hours option in a service pack.

|||

I think the frustration expressed in this thread is entirely justified and I'll ensure that the tools team here sees this.

As added weight, please go to connect.microsoft.com and give this feedback - this will open issues directly in our bug database and you will get feedback from the relevant teams.

Thanks

|||

Thanks for the suggestion! I didn't know about that site. I see a closed item where the response was that "hours" would come back as a duration in SP2. I voted for that and the open item about the same issue.

I also authored an item to make the cleanup task available through the wizard as it was in SQL2000.

Thanks for taking time to listen to our concerns and point me to the right forum for airing them. Your responsiveness does your employer proud.

|||how can I set the schedule of backup as follows using Maintenance Job.

I want to run the backup plan ever 285 mins or 4.75 hours starting at 8.15 in the morning and finishing at 9.15 at night.

I have tried but it wont let me put anything more then 60 mins or 4.75 hours.

Mits
|||

In sql2005 the retention period comes as common sql server setting.when check properties of sql server in database setting you have option to set retention period

sql

Back-up DB but keep the files for 3 days?

Hi
I

have created a job to backup all our database. It works fine and

creates .bak files in default folder. I have scheduled the task to run

every 4 hours.

My question is how can i modify or program this

backup plan to keep the backup files for only last 3 days and delete

older backup files?

Mits

That's simple. I assume you are using SQL Server 2000.
If so, in Enterprise Manager, Expand Management node, select Database Maintenance plans.
Right click the maintenance plan and select properties.
Go to the complete backup tab.
Change the "Remove files older than" option to read 3 days and click ok.

Hope that Helps.

|||

A few questions for you to think about if you haven't already:

Are the backups stored on a different physical drive than the databases? If not then they absolutely should be.|||

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.

|||

Matt Fraser wrote:

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.


Matt,

I discovered this issue as well with SQL 2005, and I am perplexed as to why we have a way to back up databases but no way to manage the retention of old backups which can cause our disks to fill up. As a workaround I found this script on the web and use it to delete backup files older than "x" days, and it has worked flawlessly from the first time I started using it.

There are a few different ways to implement this workaround, but I have found the easiest way to is to copy the code below into a Notepad and save it as a .vbs file in the root of your backup drive, you might name the file something like DeleteOldBackups.vbs. This way you would simply create a Scheduled Task that points to this file and set the task to run either before or after all of your backups complete.

Make sure you set the directory paths and number of days to meet your needs.


Option Explicit
on error resume next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld

'Delete database backup files older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\databackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database backup files are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Delete database log file backups older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\logfilebackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database log file backups are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

This has worked great for me, hopefully it will be useful to you and others as well.

|||Thank you everyone for you responses and i like the idea of script and i honestly agree with Matt Fraser.

I am using SQL Server 2005 Enterprise Edition.

I have had it working on SQL Server 2000 using a batch file using following command and this batch file was scheduled to run on sepecific time of the day. This will backup DB and Log files.

SQLMAINT -D DBName -BkUpDB E:\SQLBKUP -BkUpMedia DISK -DelBkUps

3days -VrfyBackup

The backup is taken on a shared Drive on the DB Server which will be backed up in the overall daily backup plan on tape. So everyday on tape, we will have the backup of last 3 days and we dont have to use hard disk space.

Regarding disaster recovery - we literally cant have any downtime from monday to saturday, but, couple of hours on Sunday could be arranged. Backup time is about 10-15 mins.

Yes I regularly restore the backups to check the validity.

I am quiet sure that this batch file will work for SQL Server 2005, but i not particularly keen on using batch file(and if i have to, i will use it). I want to do it through Maintenance Plan.

Mits|||

I also use script to achieve this at my customers (WMI/VB Script). It's much more flexible and you can code it to do what you want. I've done a few custom versions, if, for example, they want to keep N number of fulls, and only a certain number of days worth of transaction logs, etc.

It works very well, but as you hint at Mits, it is outside the control of SQL Server.

|||

I did some digging and I found out that there is in fact a way to delete old backup files within the SQL management studio. I was told this functionality was going to be added with SP1 and apparently it was, just not where I expected to find it. I haven't had a chance to test it very much so I'm going to continue running my VB Script, but it is there.

Basically there are two ways to create backup jobs for your databases from within the SQL management studio Maintenence Plan area, manually or by using the wizard. If you choose to create your backup plans manually you will see the functionality to delete old backups right away, but here is how I found it because I always like to use the wizard instead.

In the SQL management studio under maintenence plans, right click maintenence plans and select the wizard. Follow the wizard all the way through to create your backup plan, you will not see any option to delete backup files older than "x" days, at the end save your backup plan.

Once your backup plan is visible under maintenence plans, right click it, and click on modify, this will open your backup plan in what appears to be a development environment window and you will see several boxes connected to each other with either green or blue arrows. Look down in the lower left hand corner and you will see a toolbox with about eight different components in it.

Select the component called Maintenence Cleanup History and drag it onto the page with your other boxes. Right click this new box and click edit, when it opens up you will see options to delete backup files older than x days. You can configure it, and then you will need to connect it to the other boxes and save the plan and then run it to test it. I tried it a couple of times and couldn't get it to work so I will have to keep testing it.

The ability to delete old backup files does exit, just not where I thought I would find it.

|||thank you very much andy
I try adding cleanup history step and see if i can get it working.

Mits|||

Well done, Andy. It seems that SP1 did in fact add this functionality, but the Wizard hasn't been updated yet to include it. So, the key is to add the step for "Maintenance Cleanup Task," recognizing that it's different from "History Cleanup Task" (which is included in the Wizard).

I've added it to my maintenance plan, and in about a week's time I should know if it's working properly.

|||

This appears to work, but I won't be able to tell until tonight since Microsoft has removed the ability to delete files older than x hours. Only days, weeks, months, and years. I always used hours because of variations in backup duration. If a backup had the time of 8:01 one night and 8:00 the next, I would end up with both on the drive if I picked the 1 day option. I always used 23 hours to avoid the drive filling up. It appears that option is gone. Grrrrr! It is annoying to have a feature that you use and rely on only to have it removed.

Microsoft, please add back the hours option in a service pack.

|||

I think the frustration expressed in this thread is entirely justified and I'll ensure that the tools team here sees this.

As added weight, please go to connect.microsoft.com and give this feedback - this will open issues directly in our bug database and you will get feedback from the relevant teams.

Thanks

|||

Thanks for the suggestion! I didn't know about that site. I see a closed item where the response was that "hours" would come back as a duration in SP2. I voted for that and the open item about the same issue.

I also authored an item to make the cleanup task available through the wizard as it was in SQL2000.

Thanks for taking time to listen to our concerns and point me to the right forum for airing them. Your responsiveness does your employer proud.

|||how can I set the schedule of backup as follows using Maintenance Job.

I want to run the backup plan ever 285 mins or 4.75 hours starting at 8.15 in the morning and finishing at 9.15 at night.

I have tried but it wont let me put anything more then 60 mins or 4.75 hours.

Mits|||

In sql2005 the retention period comes as common sql server setting.when check properties of sql server in database setting you have option to set retention period

Back-up DB but keep the files for 3 days?

Hi
I

have created a job to backup all our database. It works fine and

creates .bak files in default folder. I have scheduled the task to run

every 4 hours.

My question is how can i modify or program this

backup plan to keep the backup files for only last 3 days and delete

older backup files?

Mits

That's simple. I assume you are using SQL Server 2000.
If so, in Enterprise Manager, Expand Management node, select Database Maintenance plans.
Right click the maintenance plan and select properties.
Go to the complete backup tab.
Change the "Remove files older than" option to read 3 days and click ok.

Hope that Helps.

|||

A few questions for you to think about if you haven't already:

Are the backups stored on a different physical drive than the databases? If not then they absolutely should be.|||

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.

|||

Matt Fraser wrote:

Yes, it's simple in SQL Server 2000. It's not simple at all in SQL Server 2005. We have just recently set up our first few SQL 2005 systems, and I cannot find any way to do this (remove older backup files) using the Database Maintenance Wizard, or Database Maintenance plans in general. There is a database maintenance task called "Cleanup History," but when looking deeper into this task all it does is called a system stored procedure msdb.dbo.sp_delete_backuphistory. When looking at the code for this stored procedure, it does indeed clean out the history in the msdb tables, but it doesn't reach out to the filesystem where the backup files are created and remove the older ones.

This functionality, which worked so wonderfully in SQL Server 2000 and was so central to plans involving backups staged to disk before moving them to tape, appears to have been removed in SQL Server 2005. I cannot understand why this would be so, and I hope that I am wrong and just missing something here.

I too would like to know if there is a mechanism for automatic removal of older backup files in SQL 2005.


Matt,

I discovered this issue as well with SQL 2005, and I am perplexed as to why we have a way to back up databases but no way to manage the retention of old backups which can cause our disks to fill up. As a workaround I found this script on the web and use it to delete backup files older than "x" days, and it has worked flawlessly from the first time I started using it.

There are a few different ways to implement this workaround, but I have found the easiest way to is to copy the code below into a Notepad and save it as a .vbs file in the root of your backup drive, you might name the file something like DeleteOldBackups.vbs. This way you would simply create a Scheduled Task that points to this file and set the task to run either before or after all of your backups complete.

Make sure you set the directory paths and number of days to meet your needs.


Option Explicit
on error resume next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld

'Delete database backup files older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\databackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database backup files are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Delete database log file backups older than 5 days
iDaysOld = 4
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ".\logfilebackups"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files

'If database log file backups are older than 5 days, delete them.
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next

'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

This has worked great for me, hopefully it will be useful to you and others as well.

|||Thank you everyone for you responses and i like the idea of script and i honestly agree with Matt Fraser.

I am using SQL Server 2005 Enterprise Edition.

I have had it working on SQL Server 2000 using a batch file using following command and this batch file was scheduled to run on sepecific time of the day. This will backup DB and Log files.

SQLMAINT -D DBName -BkUpDB E:\SQLBKUP -BkUpMedia DISK -DelBkUps

3days -VrfyBackup

The backup is taken on a shared Drive on the DB Server which will be backed up in the overall daily backup plan on tape. So everyday on tape, we will have the backup of last 3 days and we dont have to use hard disk space.

Regarding disaster recovery - we literally cant have any downtime from monday to saturday, but, couple of hours on Sunday could be arranged. Backup time is about 10-15 mins.

Yes I regularly restore the backups to check the validity.

I am quiet sure that this batch file will work for SQL Server 2005, but i not particularly keen on using batch file(and if i have to, i will use it). I want to do it through Maintenance Plan.

Mits|||

I also use script to achieve this at my customers (WMI/VB Script). It's much more flexible and you can code it to do what you want. I've done a few custom versions, if, for example, they want to keep N number of fulls, and only a certain number of days worth of transaction logs, etc.

It works very well, but as you hint at Mits, it is outside the control of SQL Server.

|||

I did some digging and I found out that there is in fact a way to delete old backup files within the SQL management studio. I was told this functionality was going to be added with SP1 and apparently it was, just not where I expected to find it. I haven't had a chance to test it very much so I'm going to continue running my VB Script, but it is there.

Basically there are two ways to create backup jobs for your databases from within the SQL management studio Maintenence Plan area, manually or by using the wizard. If you choose to create your backup plans manually you will see the functionality to delete old backups right away, but here is how I found it because I always like to use the wizard instead.

In the SQL management studio under maintenence plans, right click maintenence plans and select the wizard. Follow the wizard all the way through to create your backup plan, you will not see any option to delete backup files older than "x" days, at the end save your backup plan.

Once your backup plan is visible under maintenence plans, right click it, and click on modify, this will open your backup plan in what appears to be a development environment window and you will see several boxes connected to each other with either green or blue arrows. Look down in the lower left hand corner and you will see a toolbox with about eight different components in it.

Select the component called Maintenence Cleanup History and drag it onto the page with your other boxes. Right click this new box and click edit, when it opens up you will see options to delete backup files older than x days. You can configure it, and then you will need to connect it to the other boxes and save the plan and then run it to test it. I tried it a couple of times and couldn't get it to work so I will have to keep testing it.

The ability to delete old backup files does exit, just not where I thought I would find it.

|||thank you very much andy
I try adding cleanup history step and see if i can get it working.

Mits|||

Well done, Andy. It seems that SP1 did in fact add this functionality, but the Wizard hasn't been updated yet to include it. So, the key is to add the step for "Maintenance Cleanup Task," recognizing that it's different from "History Cleanup Task" (which is included in the Wizard).

I've added it to my maintenance plan, and in about a week's time I should know if it's working properly.

|||

This appears to work, but I won't be able to tell until tonight since Microsoft has removed the ability to delete files older than x hours. Only days, weeks, months, and years. I always used hours because of variations in backup duration. If a backup had the time of 8:01 one night and 8:00 the next, I would end up with both on the drive if I picked the 1 day option. I always used 23 hours to avoid the drive filling up. It appears that option is gone. Grrrrr! It is annoying to have a feature that you use and rely on only to have it removed.

Microsoft, please add back the hours option in a service pack.

|||

I think the frustration expressed in this thread is entirely justified and I'll ensure that the tools team here sees this.

As added weight, please go to connect.microsoft.com and give this feedback - this will open issues directly in our bug database and you will get feedback from the relevant teams.

Thanks

|||

Thanks for the suggestion! I didn't know about that site. I see a closed item where the response was that "hours" would come back as a duration in SP2. I voted for that and the open item about the same issue.

I also authored an item to make the cleanup task available through the wizard as it was in SQL2000.

Thanks for taking time to listen to our concerns and point me to the right forum for airing them. Your responsiveness does your employer proud.

|||how can I set the schedule of backup as follows using Maintenance Job.

I want to run the backup plan ever 285 mins or 4.75 hours starting at 8.15 in the morning and finishing at 9.15 at night.

I have tried but it wont let me put anything more then 60 mins or 4.75 hours.

Mits|||

In sql2005 the retention period comes as common sql server setting.when check properties of sql server in database setting you have option to set retention period