Introduction: Drupal 8 File & Database Backup Automation
This Tutorial will guide users to set-up an automated MySQL database backup service for Drupal 8 websites using the Backup & Migrate module & options for off-site file storage. Some of the advanced functions like NodeSquirrel & Dropbox are D7 only.
Drupal 8 administrators can choose to make a complete site file backup, a copy of the files saved by the CMS outside of Drupal 8 core, or the MySQL database export.
The Backup & Migrate module allows MySQL database backups for a Drupal 8 site to be scheduled on an hourly, weekly, or monthly basis according to owner requirements.
Step One: Install the Backup & Migrate Module for Drupal 8
To get started, download the Backup & Migrate module from drupal.org & install the files at admin/modules/install or use your choice of FTP, Git, Drush, etc. to accomplish the task according to standard web development practices for your project or team.
Required Modules - Download:
- Backup & Migrate: (download files)
Configuration: Enable the module & save the settings. It is recommended to take the Drupal 8 website offline for maintenance when installing the modules manually.
Place the website in maintenance mode at: admin/config/development/maintenance when working with the database backup system or installing new modules.
Step Two: Configure the Settings for Database Backups
After the Backup & Migrate module has been installed, navigate to: admin/config/development/backup_migrate & review the configuration settings.
On the Quick Backup page, Drupal administrators have the choice to manually download the MySQL database, site file, public file directory, or the entire website.
On the Advanced Backup page, Drupal administrators have a wide range of settings to choose the compression standard or exact tables to be downloaded from the database.
Either of these pages can be used to complete a Manual Download of a MySQL Database to a desktop computer or remote file as a backup or reference file.
Step Three: Scheduling Regular MySQL Database Backups
Scheduling regular MySQL Database backups for a Drupal 8 website can be accomplished using the Backup & Migrate module under the Schedule section.
Navigate to: admin/config/development/backup_migrate/schedule and click on the button to “Add Schedule”. Give the schedule a name and review the site configuration.
Choose “Default Drupal Database” for the backup source and the Private Files Directory for the backup destination. Then choose to backup the database on a hourly or daily schedule according to the requirements of your website content & traffic.
High traffic websites can save backups on a minute-by-minute basis to guarantee the latest changes from users are saved in emergencies. Static websites may only need a weekly or monthly backup. Save the number of files to keep according to this aspect.
It is recommended to keep 10 to 100 database backups in the Private Files Directory depending on your storage capacity & need for security, where only the last is valid.
Step Four: Uploading MySQL Database Files for Restore
If your Drupal 8 website goes offline, gets hacked, or crashes for unknown reasons, the main advantage of the Backup & Migrate module is the previous version can be restored. Navigate to the Public Files Directory & download the latest MySQL file.
Navigate to admin/config/development/backup_migrate/restore and upload the MySQL Database file from the backup folder. This will completely replace the current database.
Developers can use the Backup & Migrate module to port Drupal 8 databases between environments. The backup MySQL files are an essential part of restoring Drupal 8 websites under emergency situations, hardware crashes, or human error.
Step Five: Working with phpMyAdmin & cPanel Tools
Some of the MySQL Database backup & restore functionality is reproduced in phpMyAdmin & cPanel for Drupal 8 web publishers on shared Linux hosting plans.
In cPanel, look for the phpMyAdmin icon and click on the link to open the application. All of your domain name MySQL Databases can be administered through the software.
Click on the link for your Drupal 8 database in phpMyAdmin, then click on the “Export” tab. There are settings for a Quick & Custom export depending upon the requirements.
Use the Advanced Settings page with phpMyAdmin defaults to export the Drupal 8 database with utf-8 as standard. Additionally, check the box for the following rule set:
Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGERstatement
Although the phpMyAdmin database export files are not compatible with the MySQL Database backup files generated by the Drupal 8 module, both can be used as required in development & production to build a competent data security system.
Note: cPanel’s Backup Manager is another option on some shared Linux plans, but does not have the flexibility to set scheduled MySQL Database backups for Drupal 8.
Conclusion: Essential for Drupal 8 Website Management
The Backup & Migrate module for Drupal 8 is an excellent tool for scheduling automated MySQL backups on a regular time intervals, robust enough for enterprise traffic levels. Schedule Database Backups by second, minute, day, week, & month.
Use the Backup & Migrate module with phpMyAdmin to restore Drupal 8 websites to previous versions or when changing web hosting companies and moving files to a new web server. Keep backups in case of any crash of hardware or software malfunction.
Check out these top 3 Drupal hosting services: