Date Published: January 31, 2022
Backing up your Drupal database
Note
For information about backing up your Acquia Cloud hosted website's database, see Backing up your application.
Drupal stores the content of your website, configuration, and log information in the database. Keeping backups of the database ensures that you can recover from server disasters, easily set up testing or development copies of your website, or move your website to another environment. The best practice for you depends on the specifics of your installation and what tools you're comfortable using.
Important
Backing up your website's database does not back up your website's files.
To be able to completely restore your website from a backup, you must also separately back up your website's files.
Whatever backup method you choose, test making a backup and restoring your website from it in a test environment before relying on it as a backup strategy for a production website.
Several database backup methods are available for your use, including the following:
- Backup tools provided by your hosting provider
If you host your Drupal website with a hosting provider, they may have a service that backs up your databases. Even if these backups are handled automatically, it's good practice to ensure that you know when and how they're backed up.
For information about backing up your databases in Acquia Cloud, see Backing up your application.
- MySQL Workbench
If you have direct access to your MySQL database, MySQL offers a free open-source utility package called MySQL Workbench that allows you to administer, backup, and recover databases.
- Command-line tools
To back up your website's database using command-line tools:
- Open a command prompt window.
- Use the following
mysqldump
command to back up all of the tables in a specific database, and then save them to a file named backup.sql
(where [mysql_user]
is your MySQL username, and [database]
is the database that you want to back up):
mysqldump -u [mysql_user] -p [database] > backup.sql
Alternatively, you can export specific tables like so
mysqldump -u [mysql_user] -p [database] [table1] [table2] > backup.sql
Note
-
The mysqldump
command in the previous code snippet asks for and requires your database user password.
- Optionally, you can compress the database backup file to make the file easier to backup and store. To do this, use the following command:
Note
You can combine the backup and compression steps in this procedure by using the following command:
mysqldump -u [database_username] -p [databasename] | gzip > backup.sql.gz
- Using FTP or SCP, copy the database backup file (or the compressed backup file if you completed the previous step) to a safe location.
Did not find what you were looking for?
If this content did not answer your questions, try searching or contacting our support team for further assistance.