master.dbo.xp_delete older backup files not deleted

  • Hi

    Below Command is working with SSMS without any errors. Management plan job dos not delete older 3 days files by automatically after taking Transaction log backups.

    EXECUTE master.dbo.xp_delete_file 0,N''E:\SQL_DB_Backups\TRNLogs'',N''trn'',N''2015-02-09T11:00:35'',1

    SQL Agent service running under domain account, so this account already added into Local administrators group and also have sufficient privileges.

    Pl. suggest.

    Thanks

    ananda

  • I have tried manually run that script but not deleted old files

    declare @DeleteDate nvarchar(50)

    declare @DeleteDateTime datetime

    set @DeleteDateTime = DateAdd(hh, -48, GetDate())

    set @DeleteDate = (Select Replace(Convert(nvarchar, @DeleteDateTime, 111), '/', '-') + 'T' + Convert(nvarchar, @DeleteDateTime, 108))

    --EXECUTE master.dbo.xp_delete_file 0,N'E:\SQL_DB_Backup\Full_Backup',N'bak',@DeleteDate,1

    EXECUTE master.dbo.xp_delete_file 0,N'E:\SQL_DB_Backup\Tlog_Backup\',N'trn',@DeleteDate,1

    rgds

    ananda

  • SQL Galaxy (2/11/2015)


    SQL Agent service running under domain account, so this account already added into Local administrators group and also have sufficient privileges.

    Open explorer and check the privileges assigned, just because you put an account in the local admins group doesn't mean it can access all folders on the server. If someone has changed the ACLs then it will fail, check them carefully

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • also, try using the following as the extension

    N'BAK'

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Thank you Perry,

    management plan itself working and deleted old days backup files after adding account in backup folder and given modify privileges.

  • SQL Galaxy (2/13/2015)


    after adding account in backup folder and given modify privileges.

    😉

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

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

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