Backup
This script backs up a folder, called "backup", on your C: drive, to your U: drive. In this example the U: drive would be a USB drive, but you can change the letter to any drive you want. In addition, it makes a backup of the old backup, on the backup drive.
This script backs up a folder, called "backup", on your C: drive, to your U: drive. In this example the U: drive would be a USB drive, but you can change the letter to any drive you want. In addition, it makes a backup of the old backup, on the backup drive.
Option Explicit
Const Source = "C:\backup"
Const Destination = "U:\backup"
Const DestinationOld = "U:\backup_OLD"
Dim objFSO
On Error Resume next
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(Source) Then
Dim msg
msg = MsgBox("Press OK to begin backup to " & Destination, vbOkCancel)
If msg = vbOk Then
If objFSO.FolderExists(Destination) Then
If objFSO.FolderExists(DestinationOld) Then
objFSO.DeleteFolder(DestinationOld)
End If
objFSO.CopyFolder Destination, DestinationOld, True
objFSO.DeleteFolder Destination
End If
objFSO.CopyFolder Source, Destination, True
If Err Then
MsgBox "Error!!!"
Else
MsgBox "Backup Complete"
End If
Else
MsgBox "Backup cancelled by user."
End If
Else
MsgBox "Backup failed." & vbCrLf & "Source folder does not exist."
End If
Set objFSO = Nothing
|
