Question

mysqldump managed database through cron

From https://docs.digitalocean.com/products/databases/mysql/how-to/import-databases/#export-with-mysqldump

I got below: mysqldump -u doadmin -p -h mysql-test-do-user-4915853-0.db.ondigitalocean.com -P 25060 --single-transaction --set-gtid-purged=OFF your_database_name \

/path/to/database_file.sql

Trying to use this in a cronjob without success (adding password to above). Is it not doable to mnysqldump a digitalocean managed database through cronjob?

I noticed “The application prompts you for your MySQL doadmin user password.” from above URL. Does that mean you cant authenticate through cron command?

Thanks


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

What I could suggest is following the steps from this tutorial here on how to how to create an export script to backup your database:

https://devdojo.com/bobbyiliev/how-to-exportbackup-a-mysqlmariadb-database-with-mysqldump

It suggests the following:

In order to do that you need to make sure that you have the following content in your .my.cnf file. The file should be stored at:

/home/your_user/.my.cnf

You should make sure that it has secure permissions:

chmod 600 /home/your_user/.my.cnf

And you should add the following content:

[client]
user=your_mysql_user
password=your_mysql_password

Once you have your .my.cnf file configured, you set up a cronjob to trigger the mysqldump export of your database.

Let me know how it goes!

Best,

Bobby