Monthly Archives: February 2017

Round Robin Backup Script

This was created for a small non-profit that could not afford an expensive or recurring monthly charge for backups.
Create a directory on each computer called Backup and set permission to domain admins as well as set to hidden.
Save the text into a VBS file and set it up to run nightly


Dim da,selected
Dim DestinationPath,SourcePath,HiddenDirectory
Dim Computers
Dim shell

#computer names that have enough space to hold backup data
Computers=Array("manage1-pc","acct1-pc","work1-pc","work2-pc")

#server share that needs to be backup up
SourcePath= "d:\share\name\"

#Hiddendirectory on users computers
HiddenDirectory="Backup"

#getting the current day of the month
da=Day(now)

#This section will determine which computer it will backup to depending on the day of the month
#futurte enhancement **This needs to be rewritten to dynamically choose location so it is not relying on just four workstations **
select case da
case 1,5,9,13,17,21,25,29
selected=0
case 2,6,10,14,18,22,26,30
selected=1
case 3,7,11,15,19,23,27,31
selected=2
case 4,8,12,16,20,24,28
selected=3
end select

#function to keep all days at two digits (ie, 02,03)
Function LPad (str, pad, length)
LPad = String(length - Len(str), pad) & str
End Function

#creating the destination path to include computername, hidden directory, year, month and day in seperate folders
DestinationPath="\\"
DestinationPath=DestinationPath & Computers(selected)
DestinationPath=DestinationPath & "\C$\" & HiddenDirectory & "\"
'DestinationPath=DestinationPath & Year(Now) & LPad(Month(Now),"0",2) & LPad(Day(Now),"0",2) & "\"
DestinationPath=DestinationPath & LPad(Day(Now),"0",2) & "\"

Set shell=createobject("wscript.shell")

shell.Run("robocopy.exe " & SourcePath & " " & DestinationPath & " /mir /r:0 /w:0 /xjd /xjf /NFL /log+:d:\goodshare\BackupLogs\" & year(now) & Month(now) & ".log")