creating and deleting backup files

  • Can anyone help with the backup file's code?

    i need code for both making and deleting backup files after 7days.

    iwrote the code but its not deleting properly

    here is the code pasted-

    thank you for your time

     

    -Priyanka.

    *********************************************************

     

    '**********************************************************************

    '  Visual Basic ActiveX Script

    '************************************************************************

    Function Main()

     BackupFiles

    '''' DeleteFiles

     Main = DTSTaskExecResult_Success

    End Function

    '************************************************************************

    '  Backup Files

    '************************************************************************

    Function BackupFiles()

     Dim objFSO

     Dim CurrentDate, CurrentYear, CurrentMonth, CurrentDay, CopyFrom, CopyTo,flname,FolderPath

     CurrentDate = Date()

     CurrentYear = CStr(Year(CurrentDate))

     CurrentMonth =CStr( Month(CurrentDate))

     CurrentDay =  CStr(Day(CurrentDate))

     If CStr(Month(CurrentMonth)) < 10 Then CurrentMonth = "0" + CurrentMonth

     If CStr(Day(CurrentDay))< 10 Then CurrentDay = "0"+ CurrentDay

     CurrentDate =  CStr(CurrentYear) +"_"+ CStr(CurrentMonth)  + "_" + CStr(CurrentDay)

     CopyFrom = "\\lotus\LOTUSPOND\Telegraph"

     CopyTo = "\\Lotus\DataProcessing\BackupData\Telegraph_RE"

     Set objFSO = CreateObject("Scripting.FileSystemObject")

     objFSO.CopyFile CopyFrom & "\Feeds\131\telegraph.xml.gz", CopyTo & "\131\telegraph.xml_" & CurrentDate & ".gz", True

     objFSO.CopyFile CopyFrom & "\Feeds\132\primemove.xml", CopyTo & "\132\primemove_" & CurrentDate & ".xml", True

     objFSO.CopyFile CopyFrom & "\Feeds\134\properties.txt", CopyTo & "\134\properties_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\134\floorplans.txt", CopyTo & "\134\floorplans_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\134\images.txt", CopyTo & "\134\images_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\136.txt", CopyTo & "\135\136_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\137.txt", CopyTo & "\135\137_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\139.txt", CopyTo & "\135\139_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\140.txt", CopyTo & "\135\140_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\141.txt", CopyTo & "\135\141_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\142.txt", CopyTo & "\135\142_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\143.txt", CopyTo & "\135\143_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\144.txt", CopyTo & "\135\144_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\145.txt", CopyTo & "\135\145_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\146.txt", CopyTo & "\135\146_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\147.txt", CopyTo & "\135\147_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\148.txt", CopyTo & "\135\148_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\149.txt", CopyTo & "\135\149_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\150.txt", CopyTo & "\135\150_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\151.txt", CopyTo & "\135\151_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\152.txt", CopyTo & "\135\152_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\153.txt", CopyTo & "\135\153_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\135\154.txt", CopyTo & "\135\154_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\227\bhfeed.xml", CopyTo & "\227\bhfeed_" & CurrentDate & ".xml", True

     objFSO.CopyFile CopyFrom & "\Feeds\228\asserta_WIN.txt", CopyTo & "\228\asserta_WIN_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\228\asserta_wet.txt", CopyTo & "\228\asserta_wet_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\229\229.txt", CopyTo & "\229\229_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\232\232.txt", CopyTo & "\232\232_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\237\asserta_wett.txt", CopyTo & "\237\asserta_wett_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\241\241.BLM", CopyTo & "\241\241_" & CurrentDate & ".BLM", True

     objFSO.CopyFile CopyFrom & "\Feeds\Spicerhaart\234.txt", CopyTo & "\Spicerhaart\234_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\Spicerhaart\235.txt", CopyTo & "\Spicerhaart\235_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\Spicerhaart\236.txt", CopyTo & "\Spicerhaart\236_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\Spicerhaart\238.txt", CopyTo & "\Spicerhaart\238_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Feeds\Spicerhaart\239.txt", CopyTo & "\Spicerhaart\239_" & CurrentDate & ".txt", True

     objFSO.CopyFile CopyFrom & "\Telegraph_RE_Uploading.txt", CopyTo & "\Uploadings\Telegraph_RE_Uploading_" & CurrentDate & ".txt", True

     Set objFSO = Nothing

    End Function

    '************************************************************************

    '  Delete Files

    '************************************************************************

    Function DeleteFiles(FolderPath)

     DeleteFile "foldername"

     DeleteFile "foldername"

     DeleteFile "foldername"

    End Function

    '************************************************************************

    '  Delete File

    '************************************************************************

    Function DeleteFile(FolderPath)

     Dim FSO, Folder, File 

     Set FSO = CreateObject("Scripting.FileSystemObject")

     Set Folder = FSO.GetFolder(FolderPath)

     For Each File In Folder.Files

      If DateDiff("d", File.DateLastModified, Date()) > 7 Then FSO.DeleteFile FolderPath & "\" & File.Name, True

     Next

    End Function

    ***********************************

     

     

     

     

     

     

     

  • This was removed by the editor as SPAM

  • What are you backing up ?   Is this SQL related ?

  • I also didn't understand the problem at all.

    Is that related to SQL Server database backup at all..


    Harris/

  • If its SQL backup have ever tried SQL Maintenance Jobs cos u can set it to back up and delete backups that are older than any number of days that you specify.Please try the easy route instead of reinventing the wheel

    Thanks

    Sreejith

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

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