Is there a specific reason you want to do it with PHP ? If you use a shell script it can be as small as this:
#!/bin/sh
DATE=`/bin/date +"%G%m%d"` ;
mysqldump --host=localhost --user=YOURUSER --password=YOURPASSWORD --all-databases --single-transaction --quick | gzip > ./YOURFILEPATH/backup-$DATE.sql.gz ;
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
You can save these 3 lines as 'backup.sh' and use it when setting up your cron job. For help on setting up your cronjob, see the cpanel documentation.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
The first example on the page ...
mysqldump --host=localhost --user=YOURUSER --password=YOURPASSWORD YOURDATABASE YOURTABLE
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875