Backup a MySQL Database

database-mysql-svgIf you have a MySQL database working behind the scenes on your web site or app then creating and storing backup’s of that database can be vitally important to the operation of your business operations. A MySQL or MariaDB database uses the mysqldump command to create backups.

The mysqldumpcommand outputs a file that contains SQL statements that can be used to rebuild your database, with all of its data. Which could come in handy in the event of an unrecoverable crash or even to just move the database to a new server.

Following the steps in this guide should work on any distribution of Linux that is using MySQL or MariaDB.

Contents

  1. Review the command
  2. Convert to script
  3. Run as nightly cron job
  4. Restore database

Continue reading “Backup a MySQL Database”