Using php scripts is not recommended to make backups; you will run into several php issues, most specifically the max_time_limit variable which is usually set at 60 seconds or so (at some places, as little as 10-20 seconds).
You should instead use SSH and the built in mysql tools to make backups (I'm not going to post the queries here since i'm not at my pc, just do a search for mysql backup and you'll find it in like 20 different threads)