Wednesday, November 19, 2008

dirty little backup via batch file

I am always asked how to get a copy of backups off of the Vocera Server because backup solutions aren't part of their Vocera project. There are a million ways to skin this cat but I am going to start with the very simplest way I can think of to get a copy off to another Windows server. I may come back and detail some more advanced ways in the future, but in this case I will backup two days worth of data to my VRS from two Vocera Servers.

1) In VRS I will create two folders to share.
D:\VoceraServer01
D:\VoceraServer02

2) I map a persistent drive on each VS to it's respective folder, in my case I will do my active VS using the B drive (for Backup right?)
B:
\\VoceraReportServer\VoceraServer01
check "Reconnect at logon"
Use different username and pass if required

3) Now I need a local staging directory on my Vocera Servers, make it easy on yourself and keep the path the same on each cluster server. I will also use this to store other important things like my license key. I will make this folder ABOVE the vocera directory. Lets take off the training wheels and go to the command prompt.
"mkdir C:\ThomsBackupHack"
"cd C:\ThomsBackupHack"

4) Next we need to create a batch file to do our dirty work.
"edit BackupHack.bat"
"ALT + f" will open the File menu
"s" will save the file as C:\ThomsBackupHack\BackupHack.bat
"ALT + f" will reopen the File menu
"x" will exit the edit mode

5) Now we just need to put in the logic for what we want to do.
# This is not Thom's fault, I did this on my own :)
# Make directory to stage files in
mkdir C:\ThomsBackupHack\TEMP
# Get backups, they are the .zip files
copy C:\vocera\backup\*.zip C:\ThomsBackupHack\TEMP
# Get a copy of the badge.properties
copy C:\vocera\config\badge.properties C:\ThomsBackupHack\TEMP
# May as well grab the server properties file too
copy C:\vocera\server\Properties.txt C:\ThomsBackupHack\TEMP
# I usually put a copy of the license files in the root of c: so I grabbed that too
copy C:\mylicense.txt C:\ThomsBackupHack\TEMP
# Now that our files are together, lets cleanup our VRS directory
rmdir /S /Q B:\YesterdaysBackup
# Then we can take the folder named TodaysBackup and make it YesterdaysBackup since it's now a day old
move B:\TodaysBackup B:\YesterdaysBackup
# We should now have a clean directory for todays data
mkdir B:\TodaysBackup
# Now we can sync our staging dir on the Vocera Server to the VRS
copy C:\ThomsBackupHack\TEMP\*.* B:\TodaysBackup
# When we are done with TEMP we should clean it up
rmdir /S /Q C:\ThomsBackupHack\TEMP
# This should conclude our little backup batch file.

To be precise, my file looks like this:
mkdir C:\ThomsBackupHack\TEMP
copy C:\vocera\backup\*.zip C:\ThomsBackupHack\TEMP
copy C:\vocera\config\badge.properties C:\ThomsBackupHack\TEMP
copy C:\vocera\server\Properties.txt C:\ThomsBackupHack\TEMP
copy C:\mylicense.txt C:\ThomsBackupHack\TEMP
rmdir /S /Q B:\YesterdaysBackup
move B:\TodaysBackup B:\YesterdaysBackup
mkdir B:\TodaysBackup
copy C:\ThomsBackupHack\TEMP\*.* B:\TodaysBackup
rmdir /S /Q C:\ThomsBackupHack\TEMP

  • Now if we double click BackupHack.bat we should see a file named "TodaysBackup" in the C:\VoceraServer01 directory on the VRS.
  • If we double click it again we should now see a file named "YesterdaysBackup" in the same directory.
  • If we run a manual backup from the admin console then lauch the batch file again we should notice a new .zip in the TodaysBackup folder.
Pretty slick huh?

Now all we have to do is schedule it for just after our nightly backup runs. Mine is set to run at 2:00 am so I will return to the command line one more time:
"at 03:00 /every:M,T,W,Th,F C:\ThomsBackupHack\BackupHack.bat"

If you want to check the scheduler just type "at" at the command line for a list of scheduled jobs.

Once VoceraServer01 is done and working, you will need to duplicate on the rest of your cluster servers to be sure you are backing up the active server.

The one file I can't test backups for is telproperties.txt but combining this logic with google should get you what you need. UPDATE: that would be C:\vocera\dialogic\telproperties.txt

I should probably mention again, you should really be using an enterprise backup suite for your servers, especially mission critical ones, but this is a first level of safety net.

1 comment:

Thom said...

To answer a question I got offline, you only need the .zip to restore the database. The text files are used if you must rebuild a server from a fresh OS install, these will rarely change after the system is configured but having a copy within one day of your restore point can't hurt!