19 Sep 2014

A simple script for scheduled Access DB backups

Here's a simple wee backup script to save as a VBS file (e.g. backup.vbs) and then run from Windows Task Scheduler.

Saves a copy with a datestamp in the filename e.g. Data_2014-09-07.mdb

Dim oldfilePath
Dim newfilePath

oldfilePath = "C:\LivePath\Data.mdb"
newfilePath = "D:\Data_Backups\Data_"

newfilePath = newfilePath & datepart("yyyy", date()) & "-"
newfilePath = newfilePath & Right("0" & DatePart("m",Date), 2) & "-"
newfilePath = newfilePath & Right("0" & DatePart("d",Date), 2) & ".mdb"

Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFile oldfilePath, newfilePath, true

Set fso = Nothing
 
If I helped you out today, you can buy me a beer below. Cheers!