This is one I’ve been doing for years with every hosting company I’ve worked with and for some reason, the syntax of the command changes every time. It’s very odd. I have to keep tweaking things to make it work. This command I’ll share with you below works with my latest host. I’m using WHM and cPanel and after visiting the Cron page and filling in the frequency of the database dump, I fill in this code:
mysqldump –user=database_username –password=’database_password’ database_name | gzip > /home/account_username/database_name.sql.gz
Obviously, fill in the “database_username” and similar parts with your own information. As you can see, the zipped dump will be placed in the root directory. Always zip your database dumps because the zipping makes the files so so much smaller and easier to work with. I’m talking like 300 MBs down to 65MBs. It’s crazy.