Cycling and using AutoIT to create Firebird database backups

Submitted by andrew on Sun, 07/03/2011 - 21:19

Went out cycling today, but not on my electric bike (I recently bought an electric bike from The Electric Bicycle Co, very cool) and I finished up riding 13 kilometres overall. We rode out to the Western Plains Zoo and back and my wife took the electric bike with the kids in the trailor on the back. Was a great Sunday thing to do.

Once I returned home I was pottering around on the web and came across a reference to the gbak.exe utility that comes with the Firebird database and is used to do online backups of the database files. We use Firebird for an in-house developed payroll and invoicing system and I thought this would be a handy utility to use in automating backups of our databases.

I decided to build something using AutoIT as it can compile brilliant little executable files that will hide things like database passwords. Here is the basic AutoIT code that I used to build an exe file that I put into a directory with the gbak.exe utility and the fbclient.dll.


;Run Firebird backup routine using GBAK
RunWait("gbak.exe -user dbusername -password password ""d:\path\to\database.fdb"" ""d:\path\to\databasebackup_" & @HOUR & @MIN & "_" & @MDAY & @MON & @YEAR & ".fdb""")

Replace the variables above as needed. It will create a file with the time and date appended to the filename in a location you set. As a bonus this gbak.exe utility creates a backup file that is smaller than the original if your original file still has lots of white space.

Important Note: The gbak.exe utility will affect performance considerably so use this to backup after hours to reduce impact on users.

Next step is to just run this from our new Kaseya system (still waiting for a licence key however!).