prepare final and backup sql