A reliable backup will allow you to restore your site if something goes wrong, whether it is a server failure, site code or database problems, or user error. Everyone should have a regular back up schedule for their site, and know how to restore the site from those backups. A new backup should also be created before every update of core or a contributed project made to a site. For a Drupal site, you need to make sure to have backups for both your site code, including your site-specific settings and files, and the user-generated content that lives in the database and filesystem.
Example tasks
- Back up a database and user-generated files
- Back up Drupal site code
- Restore a Drupal site from backups
Confidence
Backups are not an integral part of Drupal itself; the procedures and tools are widely used across all web applications. This means the information is widely available and reliable.
Drupalize.Me resources
Quick reference
Using Drush:
drush sql:dump --gzip --result-file=backup.sql
Or using mysqldump, replace {DATABASE_NAME}
with the name or your MySQL database:
mysqldump -q --opt --add-drop-table {DATABASE_NAME} | gzip > backup.sql.gz
Both examples will result in a file named backup.sql.gz that contains a compressed backup of your database.
External resources
-
Backing up and migrating a site (Drupal.org)
- Community documentation covering various ways to complete and restore backups.
-
Save-as-you-go and make backups in a jiffy with DDEV-Local (ddev.com)
- Learn how to create database snapshots and restore them, and export and import database dumps using DDEV commands,
ddev snapshot
,ddev restore-snapshot
,ddev export-db
, andddev import-db
.
- Learn how to create database snapshots and restore them, and export and import database dumps using DDEV commands,