This backup method is a good choice if your Drupal website is hosted on virtual or dedicated server on Amazon AWS, Digital Ocean, Linode, ... and used Unix based operation system, like Ubuntu, Debian, Fedora, Cent OS, Amazon Linux, ...
Prepared Drupal8 backup script, ready to use Drupal8 Backup Script
https://github.com/boiler256/drupal8_backup_script
For some users, a command line interface can be hard and uncomfortable, of course, a bit more technical skill is required, but it will reward with speed and flexibility.
Let's list our steps:
- Create a dump of all files in Drupal8 website folder (drupal core + related files)
- Create MySQL dump
- Create a list of useful information about system (PHP version, Apache/Nginx configuration)
- Combine all dumps into one file
- Download to a local disk or Upload to remote backup storage(optional)
Warning, Important information
Drupal 8 sites in most cases are depend on Composer application, control files like composer.json and libraries directory 'vendor' are located one level above Drupal 8 public web directory, but the location can vary depending on a setup.
This example is based on standard Drupal 8 installation.
Our setup:
Home www folder: /home/ubuntu/web/
Drupal 8 project root folder: /home/ubuntu/web/drupal8
Drupal 8 public folder: /home/ubuntu/web/drupal8/web
Composer config file location: /home/ubuntu/web/drupal8/composer.json
Composer vendor libraries folder: /home/ubuntu/web/drupal8/vendor
cd /home/ubuntu/web/
# Archive full Drupal8 project folder
zip -r drupal8-full-backup.zip drupal8
mysqldump --user=newuser --password=newpassword --host=localhost drupal8 > drupal8-sql-dump.sql
# Include mysqldump file to the archive file
zip -ur drupal8-full-backup.zip drupal8-sql-dump.sql
# Delete sql dump file (we have added it to the Drupal8 zip archive file.
rm drupal8-sql-dump.sql
aws s3 cp drupal8-full-backup.zip s3://awstestaccount/drupal8-backups/
Fallowing best practices, we can move the backup to a second independent storage, in this case, it's Amazon S3 bucket.
To use this option, you need to install and setup Amazon "aws" command line tool.
Keep required amount of backups with Find command, as example store locally only for 15 days
Example of a differential fullbackup every day at 0:00 am
To open the crontab in your default editor:
crontab -e
Conclusion
These simple steps, are excellent way to make a solid backup solution that can be used to quickly restore your Drupal 8 site.