Fixed the order of tables in database backup so that restoring data works without running pieces of the script at a time.