In our previous post we discussed some of the issues of protecting your Vault data, and highlighted the advantages of using ADMS backups.
What we wanted to do know is give you an example of an ADMS script, break it down so you can see how it works, and then give you helpful little utility to make it all the better.
In the Advanced Configuration Guide (all versions available from Advanced Configuration Guide for Autodesk data management server) you will find “Configuring Automatic Backups” and there it will describe how to set up a scheduled task, and it also gives and example batch file.
If we all had endless supplies of disk space, then using a cascaded backup would be no issue. Unfortunately for most users this is not the case.
Also the example makes no account of errors, so that if the backup script shown fails for 2 nights, there would be no backup left to go back to (on the 1st night B would be deleted and A moved to B, on the second night B would be deleted and there would be no A).
So we have done a little bit of work on the script , here it is with section explanations
First we set up variables. This means if we want to change the Backup folder from C: to D:, we need only change the set VltFld line to handle this
REM **Set vault Folder reference
REM **SET Backup Folder Names
REM **Set vault Backup root Folder reference
REM **Set vault Backup Temp Folder reference
REM **Set vault Backup Target Folder reference
REM **Set vault Backup Cascade Folder reference
REM **Set vault Logs Folder reference
REM **Set Temp Backup Log
REM **Set Target backup log
When a Vault backup is run, a folder called VaultBackupxxxxxxxx is created, where the xxxxxxx is today’s Date and time. this means we never know what the folder is going to be called. By housing the backup in a Folder we definitely know the name of, we can then control its deletion and creation. So we Create folders A & B to hold the last and last but one backup
At this point we remove the Cascaded backup folder. If you are going to run a one backup folder system, Either REM the rmdir /Q /S %VltBckFld%%VltBckCscFld% and the later line ren %VltBckFld%%VltBckTgtFld% %VltBckcscFld% that moves the old A to B
REM **Remove and the Cascaded Backup
rmdir /Q /S %VltBckFld%%VltBckCscFld%
If the last backup failed for some reason, we may still have our temp holding folder that we need to get rid of.
REM **Remove (in case) and recreate temp Holding Folder for Backup
rmdir /Q /S %VltBckFld%%VltBckTmpFld%
We get rid of any old log files
REM **Delete old Log files
Now run the vault backup to our temporary folder. By creating a log file, we can later test to see if the backup finished or crashed out
REM **Backup up to temp folder location and to temp log file
“C:Program FilesAutodeskADMS 2011ADMS ConsoleConnectivity.ADMSConsole.exe” -Obackup -S -DBSC -B%VltBckFld%%VltBckTmpFld% -VUAdministrator -VP -L%VltlogFld%%TmpLogFile%
We check to see if the backup log file was created. this gives us a decent check on whether the backup managed to run. If there was an error but the log file was created, we will see this in the log contents.
REM **If the backup failed, there will be no log folder,
IF EXIST %VltlogFld%%TmpLogFile% GOTO SUCCESS
REM **If we are here, the backup failed, pass in the excpected log file,
REM **the email script will see this is missing
REM **and react accordingly
call EmailLogs.bat %VltlogFld%%TgtLogFile%
If the backup succeeded we can rename folders and log files (as mentioned previously, if not using a cascaded backup, REM out the A to B line)
REM **Rename backup folders
REM **Rename A to B
ren %VltBckFld%%VltBckTgtFld% %VltBckcscFld%
REM **Rename TMP to A
ren %VltBckFld%%VltBckTmpFld% %VltBckTgtFld%
REM **Rename Backup Log
ren %VltlogFld%%TmpLogFile% %TgtLogFile%
call EmailLogs.bat %VltlogFld%%TgtLogFile%
You will notice the 2 lines in the above that call EmailLogs.bat. this is a second batch file that handles informing the user of the status of the backup. To do the emailing you can use programs like Blat, but we have seen some issues with Exchange 2007, so we have written our own little mailer, CPS.MiniMailer to handle this task. You are welcome to use this and let us have feedback on any issues.
The MiniMailer config file (CPS.MiniMailer.exe.config) contains sections for all the below. By setting them in the config, you can omit them from the batch file (see this post Command Line Mailer for fuller explanation on this)
:::::::::::::: Lets set some variables ::::::::::::::
REM **Apart from the attachment, the rest of these variables
REM **can be set in teh mini mailer configuration if required
set eMailto=-t email@example.com
set eMailfrom=-f firstname.lastname@example.org
set subj=-sub “Vault Server Backup Log”
set server=-srv 192.168.88.1
set body=-b “Vault Backup Log File”
We try to find the log file (which was passed as the 1st parameter to the batch file)
::::::::::::::::: Now we run Email Sender:::::::::::::::::
IF EXIST %attach% GOTO MAILLOG
REM **Rest teh subject to an error ttype
set subj=-sub “Vault Server Backup Error”
“CPS.MiniMailer.exe” %eMailto% %eMailfrom% %subj% %body% %server%
“CPS.MiniMailer.exe” %eMailto% %eMailfrom% %subj% %body% %server% -a %attach%