Heres my script for mark. I have left it pretty much as is and just changed the server names to something easier to read.
I havent done the error checking for the folders so you must make sure that the folders are in place first eg:
server1_
week1 week2 week3
just pick out the bits you need this script is backign up three server system partitions and syncing various other data.
Watch out for wrapped lines!!!!!Code:'Backup script to handle all Server BackUps 'V 0.1 Chris Hindmarch 'FisherMore R.C High Colne 'Use at your own risk!!! 'Begin Constant Declaration Const Sync_Only = 0 Const BackUp_Path = "\\backupserver\d$" Const Ext_Drive = "\\backupserver\h$" Const BackUp_Options = "/v:yes /l:f /snap:on" Const Path1= "\\server1\c$" Const Path2= "\\server2\c$" Const Path3= "\\mailserver\c$" Const Robo_Options = "/e /zb /copyall /r:3 /w:15 /purge /xf *.tmp /log+:\\server1\c$\RoboCopyLogs\" Const Log1 = "userlog-" Const Log2 = "appslog-" Const Log3 = "scriptslog-" Const Log4 = "websitelog-" Const Log5 = "worklog-" Const Log6 = "transferlog-" 'Robocopy soucepaths Const RPath1 ="\\server1\home$\" Const RPath2 ="\\server1\app$" Const RPath3 ="\\server1\adm$\scripts" Const RPath4 ="\\server1\fmwebsite$" Const RPath5 ="\\server1\work$" 'Robocopy Destination Paths Const RDPath = "\\backupserver\d$" Const RDPath1 ="home" Const RDPath2 ="apps" Const RDPath3 ="scripts" Const RDPath4 ="fmwebsite" Const RDPath5 ="work" 'Begin Variable Declaration Dim StrBuType : StrBuType = "" Dim StrDayOftheWeek : StrDayOfTheWeek = "" Dim StrCmdLine : StrCmdLine = "" Dim StrTheDate : StrTheDate = Date 'Begin Object Declaration Set ObjFSO = CreateObject("Scripting.FileSystemObject") Set ObjShell = CreateObject("WScript.Shell") 'Begin Main code On error resume next ' Prevent errors when week folders are empty 'Get Day of the Week StrDayOfTheWeek = WeekDayName(Weekday(Now)) 'Get the date and convert "/" to "-" StrTheDate = Replace(StrTheDate,"/","-") 'Wscript.Echo StrtheDate 'Set BackUp type according to the day of the week ' IF StrDayOfTheWeek = "Friday" Then StrBuType = "NORMAL" Else StrBuType = "INCREMENTAL" End IF 'IF StrDayOfTheWeek = "FriDay" Then If Sync_Only = 0 Then IF StrDayOfTheWeek = "Friday" Then 'Delete the oldest backup in week 3 ObjFSO.DeleteFile(BackUp_Path & "\" & "server1\Week3\*.*") ObjFSO.DeleteFile(BackUp_Path & "\" & "server2\Week3\*.*") ObjFSO.DeleteFile(BackUp_Path & "\" & "mailserver\Week3\*.*") 'and Move week 2 to 3 ObjFSO.MoveFile BackUp_Path & "\" & "server1\Week2\*.*",BackUp_Path & "\" & "server1\Week3\" ObjFSO.MoveFile BackUp_Path & "\" & "server2\Week2\*.*",BackUp_Path & "\" & "server2\Week3\" ObjFSO.MoveFile BackUp_Path & "\" & "mailserver\Week2\*.*",BackUp_Path & "\" & "mailserver\Week3\" ' 'Move Week 1 to 2 ObjFSO.MoveFile BackUp_Path & "\" & "server1\Week1\*.*",BackUp_Path & "\" & "server1\Week2\" ObjFSO.MoveFile BackUp_Path & "\" & "server2\Week1\*.*",BackUp_Path & "\" & "server2\Week2\" ObjFSO.MoveFile BackUp_Path & "\" & "mailserver\Week1\*.*",BackUp_Path & "\" & "mailserver\Week2\" End IF 'Backup server1 'S:\>ntbackup backup \\server1\c$ /m normal /j "Fmdc1 C Drive BackUp" /f "\\it-cph\ 'backup$\server1\Week 1\FMDC1-18-08-2005.bkf" /v:yes /l:f /snap:on 'BackUp server1 StrCmdLine = "ntbackup backup " & Path1 & " " & "/m " & StrBuType & _ " " & "/j " & Path1 & " " & "/f " & BackUp_Path & "\server1\week1\" & _ "FMDC1-" & StrTheDate & ".bkf " & BackUp_Options ObjShell.Run StrCmdLine,1,True 'BackUp server2 StrCmdLine = "ntbackup backup " & Path2 & " " & "/m " & StrBuType & _ " " & "/j " & Path2 & " " & "/f " & BackUp_Path & "\server2\week1\" & _ "FMDC2-" & StrTheDate & ".bkf " & BackUp_Options ObjShell.Run StrCmdLine,1,True 'Backup PostOffice StrCmdLine = "ntbackup backup " & Path3 & " " & "/m " & StrBuType & _ " " & "/j " & Path3 & " " & "/f " & BackUp_Path & "\mailserver\week1\" & _ "mailserver-" & StrTheDate & ".bkf " & BackUp_Options ObjShell.Run StrCmdLine,1,True End If 'If Sync_Only = 0 Then 'Sync Apps and User Areas with Robocopy 'robocopy \\server1\home$\fmstudent\year7 g:\year7test /s /e /zb /copyall /r:3 /w:15 /purge /xf *.tmp /log:\\it-cph\backup$ 'Backup Users Files StrCmdLine = "robocopy " & RPath1 & " " & RDPath & "\" & RDPath1 & " " & Robo_Options & Log1 & StrTheDate & ".txt" ObjShell.Run StrCmdLine,1,True 'BackUp Apps StrCmdLine = "robocopy " & RPath2 & " " & RDPath & "\" & RDPath2 & " " & Robo_Options & Log2 & StrTheDate & ".txt" ObjShell.Run StrCmdLine,1,True 'Backup Scripts StrCmdLine = "robocopy " & RPath3 & " " & RDPath & "\" & RDPath3 & " " & Robo_Options & Log3 & StrTheDate & ".txt" ObjShell.Run StrCmdLine,1,True 'BackUp Website StrCmdLine = "robocopy " & RPath4 & " " & RDPath & "\" & RDPath4 & " " & Robo_Options & Log4 & StrTheDate & ".txt" ObjShell.Run StrCmdLine,1,True 'Backup work folder StrCmdLine = "robocopy " & RPath5 & " " & RDPath & "\" & RDPath5 & " " & Robo_Options & Log5 & StrTheDate & ".txt" ObjShell.Run StrCmdLine,1,True 'RobocopyCopy System Backups to Removable Drive StrCmdLine = "robocopy " & BackUp_Path & " " & Ext_Drive & " " & Robo_Options & Log6 & StrTheDate & ".txt" ObjShell.Run StrCmdLine,1,True 'Parse Log files and paste all summarys into summarys-date.txt file 'Email Summary to Admin. '****************************************************************** 'Begin Functions



LinkBack URL
About LinkBacks
Reply With Quote




