Inexpensive Server Backup Solutions
Reliable backups and a strong disaster recovery plan is a necessity for any Internet retailer. You need the ability to recover from hardware failures, accidental deletes, viruses, SQL Injection, etc… Using backup software with agents for your servers and services combined with high capacity tape drives and a silo of tapes is an excellent solution if you can afford it. I use techniques that require a bit more setup and management but have served me well when I needed restores. I currently backup MS SQL, MS DNS, MS IIS (InetPub folder and sub folders) and won’t get into specifics on how to setup your SQL backups as Microsoft has good tutorials on how to do that. Instead I’ll show you how to manage those backup files after they are created.
Step 1: Backing Up Locally
If you don’t already have it installed, download and install and WinRAR. WinRAR is a popular program for compressing and un-compressing files that supports the popular ZIP format and many others. Next, decide where to stage your backups on the local server. I prefer to dedicate one local drive for backups and make sure that drive is not part of a RAID or externally connected. In my case this drive is the Z: drive. When running MS SQL backup, backing up locally allows the backups to run extremely fast which minimizes slow response times for database queries. Below is how I stage my backup data locally.
MS SQL
Since I’m backing up locally and it runs fast, I choose to perform full backups each night instead of the popular technique of running a full backup once a week, then differentials daily. This allows me to restore faster in the case of a problem. The built in backup will increment the filename for me automatically so I drop them all in a single directory Z:\SQL\MyDatabase. These files can be rather large but I can usually get at least seven to one compression. I wrote the following script that runs after my backups. The script loops through the files in the backup directory and determines if there is a compressed version of the backup file. If it finds a compressed version it deletes the uncompressed version, if it does not find a compressed version it tells WinRAR to compress it.
Set oFSO = CreateObject("Scripting.FileSystemObject")
set objShell=CreateObject("Wscript.Shell")
dim WinRAR, myFilename, BackupDir, FTPDIR
FTPDIR = "Z:\SQL\MyDatabase\"
BackupDir = "Z:\SQL\MyDatabase\"
WinRAR = "c:\progra~1\winrar\winrar.exe a -o+ "
loopfiles
Sub LoopFiles
Set oFolder = oFSO.GetFolder(BackupDir)
For Each oFile In oFolder.Files
if lCase(oFSO.GetExtensionName(oFile)) = "bak" or lCase(oFSO.GetExtensionName(oFile)) = "trn" Then
myFilename = oFile.Name
if oFSO.FileExists(FTPDIR & myFileName & ".rar") = False then
objShell.Run WinRAR & FTPDIR & myFileName & ".rar " & backupdir & myfilename,1,True
end if
oFile.delete
End If
Next
End Sub
Because of the compression I get by using WinRAR and this script, I am able to keep a much longer history that I can restore from. Additionally it allows me to transfer files across the network and Internet much faster.
MS IIS (InetPub and subfolders)
Make sure you have a copy of RoboCopy. RoboCopy is part of the Windows 2003 Resource Kit which you can find by a search on Microsoft’s website.
For my directory structure I created a folder for each day of the week and each month of the year. I have a small batch (.bat) file that I kick off daily with the Windows Scheduled Tasks service.
RoboCopy c:\inetpub z:/Websites\Monday /mir
RoboCopy c:\windows\system32\dns z:\dns\Monday /mir
RoboCopy c:\windows\system32\inetsrv z:\iis\Monday /mir
Above is the Monday batch file. I have one for each day of the week and each month of the year. The reason I use RoboCopy is by using the /MIR switch it makes a mirror directory and is smart enough to check files to determine if they need to be copied or not. This minimizes the number of files copied daily. Again everything is backed up to my dedicated Z: drive.
MS DNS
I use the same technique for backing up my DNS files that I use for backing up my IIS files. The default location for your MS DNS files is C:\WINDOWS\system32\dns.
At this point you should have files backing up locally to your Z: drive and if needed you can restore quickly. Part one of the backup process is complete.
Step 2: Migrating backup files remotely
The first step accommodates recovering from accidental deletions, SQL Injection, etc… It even helps if you loose your database drive and need to perform a restore. It doesn’t however help as much if the main board of your server stops working and you can’t easily move your backup drive to another server. For reasons like this I migrate all my backups from each server to a backup server. Again I just use a batch file to map a drive and robo copy my data with the /mir (mirror) switch.
Having all my backup files duplicated to a single server on the network allows me to easily access and restore files to replacement or hot-spare servers without having to move and setup drives on different servers. This is especially useful if you use a hosting company and you’re servers are not easily accessible.
Until now we have been discussing local network based backups. This however does not help if the building your network is in burns down. The following is what I do to disaster proof my backups.
Download and install FileZilla Server http://filezilla-project.org/ on your backup server. Follow the directions to setup access to your backup files. You will have to decide what combination of passwords, firewall settings, and Standard FTP/SSL meets your security requirements. From the FileZilla Server interface, select Edit, settings. In the General Settings area I like to set my timeouts to zero. This allows my download software to take as much time as it needs to backup.
On a server at a remote location (your office if you use a hosting company that is at least a block away) you need to install the automated FTP software to download your backup files. I use Site Shelter http://remote-backup.com/siteshelter/ because it’s proven reliable and has a “mirror” like RoboCopy that minimizes the download by only downloading files not previously downloaded.
Using these steps you can perform reliable backups that are disaster proof. Just make sure you spend time making sure you didn’t have any errors with your backups.