maintenance plan

  • Hi,

    I dont want to use the maintenance plan wizard - for some reasons sometimes it fails.

    In there - i have it to delete all backups and trans logs older than one day(current one)..... but it doesnt happen

    How to write a job that does exactly or similar to the maintenace plan wzd so that it deletes the .bak and .trn files older than current date and also the transaction log space should not be big....  (i shouldnt be shrinking the file every now and then to clean disk space)

    Plz let me know regarding this.

    Thnx,

    Natalie.

  • Natalie,

    here is an example of the job that deletes old backups.

    The job step has to be of ActiveX  Script type. In the Command textbox enter something like this replacing MyBackupFolder with your backup folder name and path. This job should delete ALL files in the folder are  2 days old no matter what extension or attributes. If you would like to delete files only with .BAK extension or delete all files older than some number of days, you will have to modify code. Please, note that this is a generic code provided only as an example, it should be tested first on the test computer.

    Dim FSO  

    Dim Folder  

    Dim Files  

     BackupFolder = "C:\MyBackupFolder"

     Set FSO = CreateObject("Scripting.FileSystemObject")      

     Set Folder = FSO.GetFolder(BackupFolder)

             Set Files = Folder.Files

      

     

                 FOR EACH File In Files

                         

       IF DateDiff("d", Now,file.DateCreated ) = -2  THEN

          FSO.DeleteFile File,true

       END IF 

       

     NEXT

       

     

        Set Files = Nothing

        Set Folder = Nothing

        Set FSO = Nothing

    Regards,Yelena Varsha

  • This thread has been cross-posted here!







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 3 posts - 1 through 3 (of 3 total)

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