Getting ready for a Drupal site upgrade “event”? Or maybe you're facing a Drupal update challenge or an even more complex process: a migration from your current version of Drupal to the latest “bundle of Drupal functionalities”? And even if there's no “major” changes-implementing event in your schedule, you still have to regularly backup your Drupal 8 site!
Is your web host providing you with a backup plan? Great! Even so, you don't need to be some sort of “visionary” to see that it's crucially important to run your own backups, as well.
You still need to back it up yourself!
You can't depend entirely on your web hosting provider's safety net for your own invaluable data. You need to weave your own net!
And we're not going to keep “bugging you” you with the three back-ups rule (“if it doesn't exist in three different...) anymore.
Here are just 3 dark scenarios that you'd be avoiding:
- the upgrade/update/moving files process fails, you'll be left with no database and no files to restore... with no Drupal 8 site, after all
- the ever-more sophisticated hackers manage (God forbid!) to find and to exploit a security vulnerability on your website and... you know that this is no happy ending story
- your web server crashes and, as you can guess, your company website can't escape the inevitable domino effect
You see what we're trying to point out here right?
Now, let us proceed to detailing the two backup methods available to you. Yet, in many cases the web server narrows down to one option.
1.The GUI-Based Backup Method
It's the most straightforward method of the two, granting you full control and easy access to your own database.
Basically you'll get to use:
- your phpMyAdmin
- a browser-based MySql interface
- any FTP client
… to manage your database and to easily transfer your files from your server or your desktop to your Drupal 8 site
Now the GUI backup method is a two-step one:
A. You'll create a backup of your Drupal 8 site:
- just connect to your server (via the FTP client that you prefer)
- and copy your website folder to a cloud drive or to your local machine
B. You'll Backup Your Database (via PHPMyAdmin)
Now you've reached the step where you cautiously “shelter” your database, your website's most valuable “asset”!
Is your server hosting service provider offering you with a native database manager? Putting you, this way, in control of your own database?
There are just a few simple tasks to carry out for successfully backing up your database:
- Log into your PHPMyAdmin (obviously!)
- Select your database (it's right there, on the left, in the, in the dropdown box)
- Click “Export”
- Click “Select All”
- Check “Data” and “Structure”
- Click “Save as File” desktop
- Click “Go” and save your .sql file to your desktop
Turn this good practice into a habit whenever you backup your Drupal 8 site: always save your database in the same folder as your Drupal files (the ones you've just backed up)
2. The CLI-Based Method to Backup Your Drupal 8 Site
Do you feel comfortable working with a command line?
Then backing up your Dupal 8 site will be nothing but a of short sequence of simple commands to enter into your command shell.
In case you haven't yet used Drush before, you should know that it's simple to install on your computer or to add to your server. It “empowers” you to easily control various aspects of your Drupal installation.
The steps to take, when you back up your Drupal 8 site via Drush, are surprisingly (or not) similar to those specific to first backup method:
A. You'll Create a Local Copy of Your Site's Folder
First things first: you'll need to copy your live site files to a new (a test) directory (make sure you give it a suggestive name). For this, it's this command that you'll need to enter:
cp -rp /path/to/drupal_site /path/to/backup_dir
Remember to check whether the .htaccess file will have got copied, too!
B. You'll Backup Your Database
And here's the command that you'll need to enter for backuping up your priceless database:
mysqldump -u USERNAME -p'PASSWORD' DATABASENAME > /path/to/backup_dir/database-backup.sql
And you even have an alternative one that you could use:
drush sql-dump > /path/to/backup_dir/database-backup.sql
There! No more “sleepless nights” for you! Your Drupal 8 site, with all its files and its valuable database, is now safely backed up and “shielded” from the “unexpected events” factor!
Tip: always date your backups (you can just imagine the chaos you'd need to deal with if you had to restore your “latest” backup and dig through a whole “pile” of undated backup folder).
To Sum Up
How often you'll backup your Drupal 8 site is up to you.
Try to estimate the value of all the digital data stored on your website, of your company's digital identity, after all, and come up with a frequency that best suits your website.
As already mentioned, no need to turn it into a process to be carried out exclusively around “big” events planned for your Drupal site (upgrades, updates, migrations). A cyber attack or a web server problem are just two dark scenarios that have nothing to do with Drupal upgrades and all the preparation taking place around these key “events”.
Let your host service provider run its own backup and make sure you run yours, too, in parallel.
As you've already seen, both methods are more than straightforward, so you have no “excuse” for neglecting your site backup routine.