Backup MySQL DB with Cron Jobs
663   2  

Backup MySQL DB with Cron Jobs

  19 Nov 2017
  Coding Category
Backup MySQL DB with Cron Jobs

  25% more discounted by using the Giliapps as code in HostGator

Exporting MySQL DB to a sql file is usual procedure for PHP Developers and can be done with many methods. I like to use Cron Jobs. That is simple and also automatic. Just create a file with your commands to backup MySQL DB and then run it with Cron Jobs.

1. Create a folder with name backup and a file like in it, and then add this command to it:


/usr/bin/mysqldump --user=USERNAME --password=PASSWORD --host=localhost DBNAME > /home/domainfoldername/public_html/backup/db_1d_backup.sql

2. Go to cPanel and then Cron Jobs. Add a One Day time interval command like this (>/dev/null 2>&1 used for prevent Emailing from Cron Jobs):

/bin/sh /home/domainfoldername/public_html/backup/ >/dev/null 2>&1

3. Just wait for 12:00 AM (Server Time not Local Time) and check backup folder.

Author: Ismael Azaran

Do you like it? Share it with your friends.