Regular backups are essential for every Magento webshop. In this guide, you will learn how to create and restore complete backups.

What should you backup?

A complete Magento backup consists of:

  • Database: All products, orders, customers, configuration
  • Media: Images and uploads (pub/media/)
  • Code: Custom code and extensions (app/code/)
  • Configuration: app/etc/env.php and app/etc/config.php
  • Theme: Custom theme files (app/design/)

Creating a Database Backup

Via phpMyAdmin

  1. Log in to DirectAdmin
  2. Go to phpMyAdmin
  3. Select your Magento database
  4. Click on Export
  5. Choose Quick for standard export
  6. Click on Go and download the SQL file

Via Command Line

# Navigate to Magento root
cd /path/to/magento

# Create database backup with timestamp
mysqldump -u user -p database_name > backup_$(date +%Y%m%d).sql

# Or with Magento CLI
bin/magento db:dump

The CLI method saves the backup in var/backups/.

Compressed Backup

For large databases:

mysqldump -u user -p database_name | gzip > backup_$(date +%Y%m%d).sql.gz

Creating a Files Backup

Via File Manager

  1. Go to File Manager in DirectAdmin
  2. Navigate to your Magento installation
  3. Select the important folders:
    • pub/media/ (images)
    • app/code/ (custom modules)
    • app/design/ (themes)
    • app/etc/ (configuration)
  4. Click on Compress to create a ZIP
  5. Download the ZIP

Via Command Line

# Navigate to above Magento root
cd /path/to/

# Create a full backup
tar -czvf magento_backup_$(date +%Y%m%d).tar.gz magento/

# Or only specific folders
tar -czvf media_backup_$(date +%Y%m%d).tar.gz magento/pub/media/

Via FTP

  1. Connect with FTP client (FileZilla)
  2. Download the entire Magento folder
  3. Or download only critical folders

Magento Support Backup

Magento has built-in backup functionality:

Backup via Admin

  1. Go to System > Backup
  2. Choose backup type:
    • System Backup: Files only
    • Database Backup: Database only
    • Database and Media Backup: Both (recommended)
  3. Click on the desired backup button
  4. Wait until the backup is complete

Note: This method may timeout for large shops. Use the command line instead.

Backup via CLI

# Database only
bin/magento support:backup:db

# Database and code
bin/magento support:backup:code --with-database

# All support backup options
bin/magento support:backup:code --include-media --with-database

Restoring Backups

Database Restore via phpMyAdmin

  1. Go to phpMyAdmin
  2. Select your database (or create a new one)
  3. Click on Import
  4. Select your SQL backup file
  5. Click on Go

Database Restore via Command Line

# Decompress if necessary
gunzip backup.sql.gz

# Import database
mysql -u user -p database_name < backup.sql

Files Restore

  1. Upload the backup to the server (via FTP or File Manager)
  2. Extract the archive in the correct location
  3. Check file permissions
# Extracting
tar -xzvf magento_backup.tar.gz

# Restore permissions
find var generated pub/static pub/media -type d -exec chmod 755 {} \;
find var generated pub/static pub/media -type f -exec chmod 644 {} \;

Post-Restore Actions

# Clear cache
bin/magento cache:clean
bin/magento cache:flush

# Rebuild indexes
bin/magento indexer:reindex

# Compile DI
bin/magento setup:di:compile

# Deploy static content
bin/magento setup:static-content:deploy nl_NL

Automated Backups

Via Cronjob

Set up a cronjob for automated backups:

# Daily database backup at 3:00
0 3 * * * /usr/bin/mysqldump -u user -p'pass' database | gzip > /backups/db_$(date +\%Y\%m\%d).sql.gz

# Weekly full backup on Sunday at 4:00
0 4* * 0 tar -czvf /backups/full_$(date +\%Y\%m\%d).tar.gz /path/to/magento

Backup Rotation

Automatically delete old backups:

# Delete backups older than 30 days
find /backups/ -name*.gz" -mtime +30 -delete

External Backup Storage

Store backups outside the server:

  • Cloud storage (AWS S3, Google Cloud, Dropbox)
  • External FTP server
  • Local download to computer

Best Practices

  1. Daily database backups: Automate with cronjobs
  2. Weekly full backups: Including files
  3. Test your backups: Restore periodically on test environment
  4. External storage: Keep copies outside the server
  5. Document: Note where backups are stored
  6. Encryption: Encrypt sensitive backups
  7. Retention: Keep at least 30 days of history

Need Help?

We are here for you! Are you facing any issues or do you have questions? Our support team is happy to assist you personally. Send us a message via the ticket system - we usually respond within a few hours and are eager to help.