mysql backup mysqldump

How to Backup and Restore MySQL with mysqldump

Backing up and restoring a MySQL or MariaDB database is super easy. I’ve listed out a few different ways you can do it.

Example MariaDB/MySQL mysqldump Backup Commands

Simple Backup

 

Backup and Compress with gzip in a Single Command

 

Backup and Compress With Gzip.

Same as above, but also drop and recreate database on restore.

 

Plus Single Transaction

Same as above, but also backup the database and restore it in a single transaction. Which can lock some tables and cause issues for any writes you’re trying to do during backup time.

 

Bzip Instead of Gzip.

Same as above, but use bzip for compression. Bzip is slower compression so backup will take longer but results in a smaller file.

 

Restore SQL

 

Restore Gzip

 

Restore Bzip