Thursday, October 6, 2011

Database Mishap

My database file has been growing big making backups rather slow. I decided to delete old records but things took an unexpected downward turn when I punched in the wrong query. What I wanted was:

delete from table1 where (cond1 or cond2) and cond3;

But the problem was I did not include the parenthesis and that completely changed the logic:

delete from table1 where cond1 or cond2 and cond3;

Crap! Had to spent the whole day restoring lost records. Luckily, my daily backups actually work. I was able to restore all data as of 2am. Just had to reconstruct the last few hundred records from 2am to around 11am when the disaster happened.

Thank goodness too for FBExport which significantly helped in the reconstruction. I should look more into this tool for doing incremental backups. The default gbak utility does not have that capability making backups of large Firebird files over-the-network really slow.

No comments: