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.
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
mysqldumpcommand to back up all of the tables in a specific database, and then save them to a file named
[mysql_user]is your MySQL username, and
[database]is the database that you want to back up):
Alternatively, you can export specific tables like so
mysqldump -u [mysql_user] -p [database] > backup.sql
mysqldump -u [mysql_user] -p [database] [table1] [table2] > backup.sql
- Optionally, you can compress the database backup file to make the file easier to backup and store. To do this, use the following command:
- Using FTP or SCP, copy the database backup file (or the compressed backup file if you completed the previous step) to a safe location.