How to take mysql database backup using cron job in cpanel

1. Login into cpanel and you know the database name, user name password.

2. Go to Cpanel home page/dashboard.

3. In “ADVANCED” section click on “Cron Jobs”

4. Go to “Add New Cron Job” section

5. In “Comman Setting” select Cron Job occurrence nature

i.e. If you want to execute cron job for database backup every minute then select “Once Per Minute” option

6. /home/eduhubindia/db_`date +%Y%m%d%H%M`.sql

a. Above is the path of output file,2nd parameter is username of cpanel, which you can find at top right of cpanel

b. Name of DB backup file is db_`date +%Y%m%d%H%M`.sql

above code is added in file name so that timestamp can be added in dbbackup file name


7.  mysqldump -u Current User -p’Password’ eduhubin_web_db > /home/cpanel-username/db_`date +%Y%m%d%H%M`.sql

Add above command In command line


8. Click on “Add New Cron Job” button

9. Go to Cpanel home page/dashboard

10. Click on File Manager

11. Check databack file is created

Leave a Reply