Backing up your web site in a few steps

by Ventsy Popov
Yesterday I decided to deal with something I’ve been postponing since the moment I installed the blog here. I can assume every hosting company has a way to back up the data it is hosting, including in my case. Yet, I am a bit more cautious when it comes to archiving my information in case it has to be later recovered… Along with prayers to computer gods not to allow such emergencies, I usually want be prepared as well. Here is a pretty easy way for a regular backup of a web site to a local machine:


First go and get BestSync 2011 (link here)
It’s a freeware app and once installed it will let you define a sync procedure between folders (local or not). At first you have to set the folders you need to sync, and the sync direction:
Then you have to define the desired schedule for the sync and even mark the task to be run as a Windows Service, so there won’t be any need to run BestSync at Windows startup:
Well so far so good, but I wanted my backup not only to be a sync process between two folders. My goal was to have daily backup archives. Following this idea I added an .exe file as an application that had to be ran every time the sync task is finished:
The cool thing here is how I created the .exe file, which had to do the simplest thing – to get all the data from the latest backup folder and copy it to a brand new folder named with the current date and time. I wanted super simple way to do it – a script for example. So I prepared the following .vbs:
Dim fso, objFolder
strComputer = "."

' Date and time

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

For Each objItem in colItems
    dtmLocalTime = objItem.LocalDateTime
    dtmMonth = Mid(dtmLocalTime, 5, 2)
    dtmDay = Mid(dtmLocalTime, 7, 2)
    dtmYear = Left(dtmLocalTime, 4)
    dtmHour = Mid(dtmLocalTime, 9, 2)
    dtmMinutes = Mid(dtmLocalTime, 11, 2)
    dtmSeconds = Mid(dtmLocalTime, 13, 2)

strDirectory = "D:\Backups\\" & dtmYear & dtmMonth & dtmDay & "_" & dtmHour & "." & dtmMinutes 
SET fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = FSO.CreateFolder(strDirectory)
fso.CopyFolder "D:\Backups\\LatestBak", objFolder, True 
I tested it to be sure it does the job correctly. And here was the first obstacle – BestSync allowed a .bat file, .exe file or .cmd file only to be executed after a sync task. Batch file or cmd were not suitable, because I wanted everything to be in silent mode. So here is the trick - I used a little known IExpress application that can be found in C:\Windows\System32 to convert my .vbs to an exe. Here is a more in depth description how it works:

…well this is not more than 20-minute procedure to assure you’ve taken some disaster measures :). If you try it out, do not forget to test a restore scenario… backups usually work pretty well, but when it comes to restoring… right?

Tags: ,