Cosi funziona, ma come faccio ad avere $contents?
codice:
$handle = fopen("$backup/backup.txt", "w");
for ($i=0;$i<count($contenuto);$i++){

fwrite($handle, $contenuto[$i]);

}

fclose($handle);

$filename = 'backup.txt';
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename='.basename( $filename ) );
header( 'Content-Length:'.strlen( $content ) );
header( 'Content-Transfer-Encoding: binary' );
exit(0);