How to automate a MySQL database backup on a hosted service? Cron job not working

I have a website on a shared hosting service provider (Bluehost). While they have many tools available, I am not able to identify a tool for automating database back-ups.

I am also very new to programming / understanding everything about web servers and databases. I know that my webserver is a LAMP stack.

Based on some Google searches, I tried to accomplish this with a scheduled cron job, but it is not working. I’m not sure my syntax and/or pathing is incorrect. Here is the error message I get when I try to run it:

/bin/sh: /home/example1_myusername/db_backup_exampledb1.sql: No such file or directory

I am not at all familiar with the proper syntax, and perhaps my path is wrong too.

I have create a couple databases for my site. When I create a database through the site wizard, the database name is comprised of two parts (i.e: example1_exampledb1 and example1_exampledb2 )

I am uncertain if the database is “example1” or of it is “example1_exampledb1”. When I log into phpMyAdmin, in the left navigation pane it shows me the name of: example1. Then under that, there are two expandable + buttons, one for exampledb1 and one for exampledb2.

The cron job syntax I am running (which I got from a Google search on the net) is:

/usr/bin/mysqldump -uexample1_exampledb -pmyPassWord dbname > /home/example1_myUserId/db_backup_forumdata$date.sql

Can someone please either advise how I can alter my cron job to make this work, or alternatively identify another way which I can automate database back ups?

They appear to have an automated Site Backup and Restore tool that covers your database tables.

Perhaps this can help. :slight_smile: