More SQL backend stuff, i'll push more later but perhaps somebody is bored and wants to review code

although now that I'm reworking exit code checking I'm starting to wonder if we even need the local db
I use [logrotate](http://linuxcommand.org/man_pages/logrotate8.html) and it works quite well! FYI