Create and restore MySQL/MariaDB backups

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.


To back up just the application database, create a dump file using the mysqldump tool. In this example, the database is named bitnami_app; replace this with the name of the database you wish to export.

$ mysqldump -u root -p bitnami_app > backup.sql

To back up all the databases, use this command instead:

$ mysqldump -A -u root -p > backup.sql

This operation could take some time depending on the database sizes.

NOTE: The steps previously described will only back up the data contained inside your databases. There may be other files that you should take into account when performing a full backup, such as files that may have been uploaded to your application. Refer to your application’s documentation for more details.


Once you have the backup file, you can restore the data with a command like the one below:

$ mysql -u root -p < backup.sql

To restore the data to a specific database, include the database name in the command, as shown below. For example, to import the data to a database named bitnami_app, use this command:

$ mysql -u root -p -D bitnami_app < backup.sql
Last modification April 8, 2020