I want a PHP cron script to be set up with cPanel cron jobs that would take backup of MySQL database.
Regards,
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 ;
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 ;
Can you please guide me how to get the shell script do the job for me? I have not used shell scripts before.
Thanks for the hint and guidance.
Thanks,
The command works for me. Could you please help me little bit more? what will be the parameter for backing up a single or multiple table?
You can find all parameters here: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
I have referred to the document above but not able to provide the options correctly. Could you please place the options in your given command?
The first example on the page ...
mysqldump --host=localhost --user=YOURUSER --password=YOURPASSWORD YOURDATABASE YOURTABLE
The first example on the page ...
mysqldump --host=localhost --user=YOURUSER --password=YOURPASSWORD YOURDATABASE YOURTABLE
Thanks, I really appreciate your efforts to help me out.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.