Thursday, August 27, 2009

HEAT: Automated Haf Files Overnight

A client asked: I have heard that there is a way to automatically create a haf every night but I cannot find any documentation to do it. Does it exist?

One way to do this is to create a BATCH file. Call the batch file autohaf.bat and use the server Task Manager run it nightly. It renames the file to the date created so it saves all haf files created.

If you have not used batch files:
* Copy/paste the script below into NOTEPAD
* Save as autohaf with the .BAT extension
* Insert your database name (unless it is HEAT)
* Insert your Admin name and password.
* Make sure the user name has rights to export HAF files

===========================================================

echo off
cls
echo This file creates a HEAT archive file from the production HEAT database
echo .
echo Creating .haf file
echo .
echo Please wait....
echo .
"C:\Program Files\HEAT\LoadDB.exe" /d "HEAT" /u "Admin" /p "password" /e "C:\HAF\backup.haf"
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set weekday=%%a& set day=%%b& set month=%%c& set year=%%d)
echo Renaming file to include todays date of %day% %month% %year%

ren c:\haf\backup.haf "backup_%day%_%month%_%year%.haf"
echo .
del c:\haf\fcactinkcom.txt
echo Backup and renaming of file complete

pause

ren Command Lines:
ren /d – ODBC Datasource name
ren /u – HEAT UserID that has rights to export HAF files
ren /p – Password of the HEAT UserID above
ren /e – Export directory including name of HAF file

===========================================================

Another option is to create a SQL backup prior to committing an edit set. This can often be quicker. However, since edit sets and haf files are interconnected, use haf files if you are making changes all the time.

1 comment:

Marc Proulx said...

why does it work at times and not at others.

Having a hard time getting it to be consistent when creating the haf file or should I say exporting.

marc.proulx@brookfieldpower.com