fixed bug in exporting database in a scheduled job