Someone on PHP-Classes just released a backup script, might want to look there. Though with the script I'm thinking about it basically creates the backup and then uploads it to your computer for offsite storage.
If you have CRON access then I would look at a PERL script. Reason being even on the command line PHP does have a timeout associated with it. Yes you can adjust said timeout but I found that not to be very stable up to version 4 of PHP (maybe 5 is).
Basically what the PERL program does is executes a system call to mysqldump + gzip and puts said backup into a directory that is NOT web accessible. After the backup is made it then looks at the directory, puts the files in an array based on time stamp and if the array is larger then 10 entries it then deletes the last X filenames in the array. So we have 10 backups in 6 hour increments. You are going to want to have something that deletes those backups after a certain amount of time or you'll fill your hard drive pretty quickly. Don't rely on yourself to delete these, if you go away for a couple days or forget the server doesn't do well when the hard drive is full

try hotscripts.com and look in the PERL section
