Everyone knows the importance of taking regular backup of their website’s data. However, few website owners actually bother to learn how to backup 8 website correctly.
If you own a Drupal website, it is absolutely crucial that you take regular backups. A consistent (and strictly enforced) backup schedule ensures that in the case of a disaster, your data remains protected at all times. The unfortunate fact about machines, in general, is that you never know when something might go wrong with them. Thus, data backups are often the only recovery option available to website owners.
In this article, I will cover the backup process for a Drupal 8 website. There are 2 ways of taking backup of Drupal 8 website:
- GUI based backup
- CLI based backup
GUI Based Backup
This is the easiest method of taking the backup of Drupal 8 website. The process has two steps:
- Backup your website folder
- Backup your database
Backup Your Website Folder
To backup your website folder, connect to your server using an FTP client of your choice (I prefer FileZilla). Once connected, copy the entire website folder to your local machine or to a cloud drive.
Backup Your Database
The next thing you need to do is to backup your database. The database contains all the data of the website and perhaps the most important component of your website. You can backup the database using PhpMyAdmin. Many hosting providers offers a native database manager that allows native database manipulation. Simply export the database to your local machine or your cloud drive.
That’s it. You have successfully backed up your Drupal 8 website using the GUI-based method.
Backup Using CLI
You can also backup your website using the command line for Drupal. This method is slightly more complex since it requires the use of the command shell. The steps in this process are basically similar. You create a local copy of the website’s folder and export the database.
Backup Website’s Folder
To copy the website files, use this command:
cp -rp /path/to/drupal_site /path/to/backup_dir
To backup the database, use this command:
mysqldump -u USERNAME -p'PASSWORD' DATABASENAME > /path/to/backup_dir/database-backup.sql
Alternatively, you can use the following Drush command:
drush sql-dump > /path/to/backup_dir/database-backup.sql
That’s it. You now know how to backup Drupal 8 site successfully. With this backup, you have a rollback point to revert to in case of a disaster. I recommend that you set up a regular schedule so that you have a very recent rollback point that you could restore your website in case of a disaster.
It is worth mentioning here that if you host your Drupal website on Cloudways, your website will be automatically backed up at regular intervals without you having to worry about the process, Cloudways also help in improving Drupal website performance see this blog post on: How To Improve Drupal’s Performance Through Cloudways.
If you have a confusion about the backup process, drop a comment below and I will get back to you.