How To backup phpMyAdmin sql on Ubuntu 18.04. (wordpress)

Hi, How to auto backup SQL backup on phpmyadmin? I use wordpress how can I get sql backups?


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

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.

Hi @erhanpaker1!

I created a wordpress server via Digitalocean backup did not work

DigitalOcean does not specifically offer backups of MySQL on a droplet, you can use DigitalOcean backups for the whole droplet, but that does not give you a database dump that you can restore by itself.

You need to handle database backups on your own and there are many ways that range from automated services that need minimal configuration which you can use to help you do the job, to custom scripts that you could use and tailor to your exact needs.

The problem with relying on scripts is that they have too many points of failure and unless you know and test what you are doing you may risk not having your backups running as expected. We wrote a guide to dump and upload backups offsite step by step that you may find helpful here.

How To Backup All MySQL Databases ?

If you choose the backup script method and want to store MySQL backups locally, you could use the suggested and nicely written answer of @bobbyiliev but modify the dump command to:

$ mysqldump -u your_username -p --all-databases > alldatabases-$(date +%F).sql

Note that we use the --all-databases argument to dump all databases instead of specifying a particular one.

Also make sure to modify the cron job entry to:

0 10,22 * * * /usr/bin/mysqldump -u your_username --all-databases > alldatabases-$(date +%F).sql

Also note that to run mysqldump without a password, you need to add your MySQL username and password to my.cnf.

For example:


Restoring a MySQL dump ?

$ mysqldump -u your_username -p < alldatabases.sql

Note that you need to obviously replace alldatabases.sql by the actual name of the dump containing all databases.

If you decide to use an automated service, check out ours, it will be helpful in this case.

Best, Islam @ SimpleBackups

Hi there @bobbyiliev

How To Backup All MySQL Databases ?

Restoring a MySQL dump ?

I created a wordpress server via Digitalocean backup did not work

Hi there @erhanpaker1,

I could suggest using musqldump with a cron job to do the backups rather than PHPmyAdmin.

The command that you would need to use is the following:

  1. mysqldump -u your_username -p your_database_name > your_database_name-$(date +%F).sql

Rundown of the arguments:

  • -u : needs to be followed by your MySQL username
  • -p : indicates that you would be prompted for your MySQL password
  • > : indicates that the output of the command should be stored in the .sql file (that you specify after that sign

Then to add a cron job you could do the following, first edit your crontab:

  1. crontab -e

Then add the following cron job:

0 10,22 * * * -u your_username -pyour_password your_database_name > your_database_name-$(date +%F).sql

For more information, you could take a look at this tutorial here.

Let me know if you have any questions. Regards, Bobby