InterSET

mysql database backup using cron job in cpanel daily weekly monthly

mysql database backup using cron job in cpanel daily weekly monthly

Share Now:

Share on facebook
Share on linkedin
Share on twitter
Share on email

1. Login into cpanel

2. In “DATABASES” section click on “MYSQL Databases”

3. Select database name under “Current Databases” section, replace database name in cron command

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

4. Select user under “Current Users” section

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

5. Click on “Change Password” under “Current Users” section. Enter New Password and click on “Change Password” button

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

Put password in cron job command

Note: There is no space between p and password command

6. Go to Cpanel home page/dashboard

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

8. Go to “Add New Cron Job” section

9. 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

10. /home/interset/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 filename so that timestamp can be added in dbbackup file name

10. /usr/bin/mysqldump -u Current User -p’Password’ interset_web_db > /home/cpanel-username/db_`date +\%Y\%m\%d\%H\%M`.sql

Add above command In command line

11. Click on “Add New Cron Job” button

12. Go to Cpanel home page/dashboard

13. Click on File Manager

14. Check databack file is created

Get Free Access to InterSet’s 1 GB SSD Hosting with Website Design


Know Your Entity Destiny Offers Savings

More You Would be interested in . . .

Have you any Question ?
Ask us !