SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


LiteSpeed and xp_delete_file


LiteSpeed and xp_delete_file

Author
Message
Anders Pedersen
Anders Pedersen
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3884 Visits: 902
I have the following statement:

EXECUTE master.dbo.xp_delete_file 0,N'M:\Backups\db_admin',N'bkp', N'2007-10-28 18:34:26'

For files created with native SQL backup this deletes the files just fine, but for files created using LiteSpeed it simply fails to delete the files. Anyone run into this?

Thanks.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)

Group: Administrators
Points: 179652 Visits: 19497
I haven't. HAve you checked the security on the files created each way?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Anders Pedersen
Anders Pedersen
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3884 Visits: 902
I did some more testing this morning.... Looks like that XP only deletes files that where created by a SQL maintenance plan, or by SQL native backups. Guess that is what I get for using an undocumented feature.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)

Group: Administrators
Points: 179652 Visits: 19497
I think I remember seeing this as well. It looks for specific extensions. I thought this changed in SP2, have you applied that?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Anders Pedersen
Anders Pedersen
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3884 Visits: 902
It's on SP2, and I tried it with the same extension name as well.

Before running my delete statement right now I have two files in a directory:
AndersTest.bak backed up with SQL, creation time of 11/1/2007 @ 7:21 AM
AndersTest_DB_20071101130.BAK backed up with LiteSpeed, creation time 11/1/2007 @ 2:14 AM

After running:

EXECUTE master.dbo.xp_delete_file 0,N'M:\Backups\AndersTest',N'bak', N'2007-11-01 07:30:22'

The LiteSpeed file is left.

To verify that it was not something in the LiteSpeed backup preventing it from being deleted, I created a file in notepad and saved it as AndersText.bak, this file did not get deleted either.

To make sure security is not the problem I logged into the desktop on the server using the same login as the SQL Agent uses, I could then delete both the LiteSpeed backup and the fake backup file.

My only conclussion is that xp_delete_file either looks at the content of the file, or looks into the backup information tables to see if it was backed up using SQL or not. I do believe the first to be the case since I have a job that sends me a list of the last backup data for each database and it clearly shows me the dates that LiteSpeed backed up the databases.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)

Group: Administrators
Points: 179652 Visits: 19497
My guess is it's looking at the backup history in MSDB, maybe even logging. I should test this by removing some backup info from the tables or replacing the file with one of a different type, same name.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Anders Pedersen
Anders Pedersen
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3884 Visits: 902
Just made a SQL backup on one server, copied the file to another SQL server. The XP_Delete_file removed it just fine.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)

Group: Administrators
Points: 179652 Visits: 19497
Good to know. They must be reading the file informaiton.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Anders Pedersen
Anders Pedersen
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3884 Visits: 902
Solution found Wink

Make my own (well, one of our programmers did) C# program that will do what I want. Guess I could have made a CLR program and exposed it to SQL, but decided to keep it simple and make it a regular EXE.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)SSC Guru (179K reputation)

Group: Administrators
Points: 179652 Visits: 19497
Is this a SSIS add-in? Your programmer (or you) interested in writing and article and sharing?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search