'---------------------------------------------------------------------------- ' Script Name: BackupCopy ' Version: 1.0 ' Purpose: To copy backup files from a local folder to a remote copmputer ' to provide remote data backup/restore ability. ' Creator: ydns ' Requirements: The need the following to run this script, ' 1) General understanding of Windows security ' including NTFS permissions, firewalls and shares. ' 2) Backup files (usually the built-in Backup ' program in Windows XP). ' 3) Windows File Sharing turned on for the computer ' you will be copying files TO. ' 4) A folder share setup on the remote computer ' such as \\server\backups. ' 5) A username and password that has access to ' the remote share and NTFS permissions. ' 6) I recommend running this as a Scheduled Task ' by a user account that is in the Backup Operators ' group and whose sole purpose is making backups. ' ' Notes: This script needs you to make your backups with NTBackup ' or some other backup program that saves the backup as a ' single file. '---------------------------------------------------------------------------- 'on error resume next Option Explicit Dim objNetwork, strUserName, strUserPwd, strRemoteDriveLetter, strBackupLocation dim strLocalBackupFolder, strSourceFile(), clDrives, i const FSO_COPY_OVERWRITE = true Set objNetwork = CreateObject("WScript.Network") redim strSourceFile(1) '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- ' Set these to match the stuff you have '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- strRemoteDriveLetter = "S:" strBackupLocation = "\\remoteserver\backups" strUserName = "remoteserver\tasks" strUserPwd = "Enter the users password here" strLocalBackupFolder = "C:\backups" ' This array holds each of the files to be copied ' ** You may not use wildcards (it confuses the script) strSourceFile(0) = "C-and-SystemState-Automated.bkf" strSourceFile(1) = "SystemState-Automated.bkf" ' ** You can create strSourceFile(2) and so on just use the same ' syntax. ' ' ******* And what ever the number of files used is, place it in the ' line below in parentheses. ' I have two files to copy, so the number is 2. redim preserve strSourceFile(2) '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- ' DO NOT TRESPASS BELOW UNLESS YOU KNOW WHAT YOU ARE DOING! '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- '---------------------------------------------------------------------------- Set clDrives = objNetwork.EnumNetworkDrives For i = 0 to clDrives.Count -1 if clDrives.Item(i) = strRemoteDriveLetter then objNetwork.RemoveNetworkDrive strRemoteDriveLetter end if Next objNetwork.MapNetworkDrive strRemoteDriveLetter, strBackupLocation, "false", strUserName , strUserPwd dim filesys, fsourcefile, fdestfile for i = 0 to ubound(strSourceFile) - 1 set filesys=CreateObject("Scripting.FileSystemObject") If filesys.FileExists(strLocalBackupFolder & "\" & strSourceFile(i) ) Then If filesys.FileExists(strRemoteDriveLetter & "\" & strSourceFile(i) ) Then Set fsourcefile = filesys.GetFile(strLocalBackupFolder & "\" & strSourceFile(i) ) Set fdestfile = filesys.GetFile(strRemoteDriveLetter & "\" & strSourceFile(i) ) if datediff("h", fdestfile.DateLastModified, fsourcefile.DateLastModified) >= 23 then wscript.echo "Copying " & strSourceFile(i) & " over to " & strRemoteDriveLetter & "\" filesys.CopyFile strLocalBackupFolder & "\" & strSourceFile(i) , strRemoteDriveLetter & "\", FSO_COPY_OVERWRITE wscript.echo "You have copied " & strSourceFile(i) & " over to " & strRemoteDriveLetter & "\" else wscript.echo "The file " & strSourceFile(i) & " is really close to the same date, not copying." & _ vbcrlf & " (This saves on bandwidth)" end if Set fsourcefile = nothing Set fdestfile = nothing else wscript.echo "Copying " & strSourceFile(i) & " over to " & strRemoteDriveLetter & "\" filesys.CopyFile strLocalBackupFolder & "\" & strSourceFile(i) , strRemoteDriveLetter & "\", FSO_COPY_OVERWRITE wscript.echo "You have copied " & strSourceFile(i) & " over to " & strRemoteDriveLetter & "\" end if else wscript.echo "The file " & strSourceFile(i) & " was not copied because it didn't exist. Please check the path to the file and try again." End If next objNetwork.RemoveNetworkDrive strRemoteDriveLetter set filesys= nothing Set objNetwork = nothing WScript.Quit