Clean Up Maintainence Task

  • I have created a maintainence cleanup task.

    Basically I have to created a task to clean up .bak,.trn files that are older than two days.

    I see that the job is successful but still it not deleting the files.

    I am on SP3 for sql server 2005,I install and nothing worked.

    Can anyone of you please share the script to clean up these.

  • This task will work for you. a few things to check. Do you have files that are older than that date? Are you sure the paths in the task are set correctly?

  • Yes I have checked all that you are asking me.

    I am unable to make them work.

    I am doing everthing rite but no use.

    Hope someone can help me out.

  • Have you enabled logging? Are you using the paths for backups set by SQL Server, or have you created your own folders? Have set security correctly for the SQL Server Agent? IS this on the local machine or are these remote drives?

  • if i remember rightly there is one little "gotcha" in the maintenance plan cleanup job which is around the file extension. If i remember correctly you have to put the . in the extension name, so it should be ".bak" or ".trn" rather than just "bak" or "trn".

    It could be the other way round (that you dont need the . - i cant remember which it is :-P), i just know its caught me out a few times in the past

    John

  • From the maintenance cleanup task - click on the button to see the generated code and paste that here.

    First, when using the task - you can either cleanup backup files, transaction log backup files or report files. When you put the extension in - DO NOT PUT a period and specify only one type of file.

    For example, the task to cleanup backup files would have bak. For transaction log backups you would put in trn in a separate task.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Hi Williams,

    you made my day,Exactly I should not have the period infront of bak file.

    I am specifying as .bak

  • I should check all that.Thank you for you help Steve.

  • revanthanne (10/26/2009)


    Hi Williams,

    you made my day,Exactly I should not have the period infront of bak file.

    I am specifying as .bak

    Great - glad you were able to get this to work. Lots of people get caught by putting the period in the extension.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • [you made my day,Exactly I should not have the period infront of bak file.

    I am specifying as .bak

    Haaa...gud. Whenever we do something new we gotta check everything left and right. Such things have happend to me many times when I took over as SQL Server DBA.

  • Thanks

  • Can a similar task be setup to cleanup old audit trace files (extension trc)? because I tried with no luck (I chose type "backup files" and also type text "maint. plan text reports" - the only two available options).

  • omer_abdalla (1/11/2011)


    Can a similar task be setup to cleanup old audit trace files (extension trc)? because I tried with no luck (I chose type "backup files" and also type text "maint. plan text reports" - the only two available options).

    No, the extended procedure xp_delete_files only works on SQL Server database backup files and text report files.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • I think I m doing it right but still the task doesnt delete the files after the backup is completed

    Some one mentioned the security of the backup folder how do I change that to let the agent delete the files if thats sound the only reason

Viewing 14 posts - 1 through 13 (of 13 total)

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