Du matar inte ut din $final
data. Jag använder den här koden för att göra exakt samma sak, prova...
header('Content-Description: File Transfer');
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $backup_filename . '.sql');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . strlen($final));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
echo $final;