Now that you have a basic understanding of how to do backups and restoration of MySQL databases, it's time to automate the backup process. One of the simplest methods is to use a PHP script to backup a MySQL database, then use your hosting cron feature to periodically run the PHP script depending on your backup needs (daily, weekly, or monthly).
For details, you can download the script, extract and test. Read the details inside cronmysqlbackup.php, those commented lines provide a good introduction for beginners. The actual steps are illustrated in Step 11 inside cronmysqlbackup.php and it is:
1.) Define your website MySQL login credentials such as username, password, hostname, database name, and so forth.
2.) Define the path to your cronmysqlbackup folder as defined by $full_serverpath_to_backup. You can optionally add other databases aside from your main website database.
3.) Decide how many days will you delete the old MySQL files. The unit is in days.
4.) Finally upload the cronmysqlbackup folder with cronmysqlbackup.php and .htaccess to the path above your web root.
5.) Enable hosting cron to automatically run this script at intervals you choose e.g. weekly, monthly
The path that you have uploaded should be the same path as what you have declared in $full_serverpath_to_backup
The concept of implementation for that script relies on mysqldump command, as you can see in these lines: