How To Backup MySQL Databases With mysqldump

Mysql database should be backed up daily or periodically. It is possible to back up regularly with a script that we will create in the operating system for the backup process. We can use the mysqldump tool for backup.

We can create and schedule a shell script like the one below.

Backup All MySQL Databases

Create a script named mysql_backup.sh with the following content. The script will create a backup file for all databases.

Let’s make the script executable.

mysqldump Exclude Database

With the grep -Ev command, we can specify directories that are not associated with the database in the data directory, or databases that we do not want to back up.

Create a Crontab For Backing up Databases Regularly

FAdd the script to crontab to back it up periodically.

dbtut
Author: dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *