Archive for 9 June 2013

MySQL Backup Engine

Finally, I got around to updating my database backup utility! I started by creating a MySQL connection library and a “Backup Engine” library, which I hooked up to a test console app. This approach will allow me to have two different applications that use the same back end. One application will be a windows client and the there will be a command line utility as well.

The original version was created over a year ago and hasn’t been worked on until now.

The new project consists of:

  • Database connection library
  • Database Backup engine
  • Commandline app
  • Windows forms app

It saves backup into .sql files of predefined size. I created a DynamicFile class which saves text data into multiple files and allows the programmer to get the list of filenames afterwards:

Actually, I extended this class into DynamicSqlFile and created some methods useful for writing SQL files:

It has a handful of useful methods, like WriteComment(), which automatically appends “– ” before the text and ends it with a NewLine character. It also returns and instance of itself, making this possible:

Which makes for very compact and readable code. It ends up looking like this in the SQL file:

Commandline interface:

cmd_backup

Work in progress

Work in progress