How to Back Up and Restore a Drupal/Joomla Site

A complete backup strategy for Drupal or Joomla needs to cover both the database (content, configuration, users) and the file system (uploaded media, custom code, configuration files). This guide covers a reliable approach for both platforms.

What to Back Up

  • Database — content, configuration, user accounts
  • Uploaded files/media — images, documents, and other user-uploaded content
  • Custom code — custom modules/extensions, themes, and configuration files

Backing Up the Database

mysqldump -u backup_user -p'PASSWORD' drupal_db | gzip > /var/backups/drupal-db-$(date +%F).sql.gz

Substitute your actual database name (Drupal or Joomla) — the command structure is identical for both.

Backing Up Files

# Drupal
rsync -avz /var/www/drupal/web/sites/default/files/ /var/backups/drupal-files/

# Joomla
rsync -avz /var/www/joomla/images/ /var/backups/joomla-files/

Backing Up Configuration (Drupal-Specific)

Drupal's configuration management system lets you export configuration as YAML files, separate from the database — useful for version-controlling site configuration alongside code:

drush config:export

Automating the Backup Process

sudo nano /usr/local/bin/backup-cms.sh
#!/bin/bash
TIMESTAMP=$(date +%F)
mysqldump -u backup_user -p'PASSWORD' cms_db | gzip > /var/backups/cms-db-$TIMESTAMP.sql.gz
rsync -avz /var/www/cms/files/ /var/backups/cms-files/
find /var/backups -name "cms-db-*.sql.gz" -mtime +14 -delete
sudo crontab -e
0 2 * * * /usr/local/bin/backup-cms.sh

Storing Backups Off-Server

See How to Back Up to Object Storage (S3-Compatible) — essential for genuine disaster recovery, not just protection against accidental content deletion.

Restoring the Database

gunzip < cms-db-BACKUP_DATE.sql.gz | mysql -u user -p cms_db

Restoring Files

rsync -avz /var/backups/cms-files/ /var/www/cms/files/
sudo chown -R www-data:www-data /var/www/cms/files/

Restoring Drupal Configuration

drush config:import

Testing Restores Periodically

Restore a backup to a staging environment periodically to confirm backups are actually valid and complete — an assumption that backups "probably work" isn't a substitute for verifying it.

Before Any Major Update

Always take a fresh, verified backup immediately before applying core updates or installing new modules/extensions — these are the highest-risk moments for something going wrong.

Common Errors

Restored site shows database connection errors — verify the restored database credentials match what's configured in settings.php (Drupal) or configuration.php (Joomla) on the destination server.

Continue Reading

Browse more articles in CMS Platforms Beyond WordPress.

  • drupal backup, joomla backup, cms backup restore, drush config export
  • 0 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

How to Install Drupal on a VPS

Drupal is a powerful, highly flexible open-source CMS well-suited for complex content structures,...

How to Install Joomla on a VPS

Joomla is a mature, feature-rich open-source CMS offering a middle ground between WordPress's...

How to Install Craft CMS on a VPS

Craft CMS is a developer-friendly, content-first CMS known for its flexible content modeling and...

How to Install TYPO3 on a VPS

TYPO3 is an enterprise-grade CMS widely used in Europe for large, complex websites needing...

How to Install Grav (Flat-File CMS) on a VPS

Grav is a modern, flat-file CMS — it stores content as files rather than in a database,...