Skip to main content
The backup-all-sites command creates backups of all sites in the current bench, including database dumps and file backups.

Usage

bench backup-all-sites

What Gets Backed Up

For each site in the bench, the command backs up:
  1. Database - Full SQL dump of the site’s database
  2. Private Files - Files in the site’s private directory
  3. Public Files - Files in the site’s public directory (optional)

Backup Location

Backups are stored in each site’s sites/[sitename]/private/backups/ directory:
sites/
  site1.local/
    private/
      backups/
        20260305_143022-site1_local-database.sql.gz
        20260305_143022-site1_local-private-files.tar
        20260305_143022-site1_local-site_config_backup.json

Examples

Basic Backup

# Backup all sites
cd ~/frappe-bench
bench backup-all-sites
Output:
Backing up site1.local...
Backup Summary for site1.local at 2026-03-05 14:30:22
================================================
Backup Path: ./sites/site1.local/private/backups/
Database: 20260305_143022-site1_local-database.sql.gz
Private Files: 20260305_143022-site1_local-private-files.tar
Config: 20260305_143022-site1_local-site_config_backup.json

Backing up site2.local...
[...]

Backup Before Update

# Backup before running updates
bench backup-all-sites
bench update
The bench update command automatically backs up sites by default unless you use the --no-backup flag.

Automated Backups with Cron

# Add to crontab for daily backups at 2 AM
crontab -e
Add:
0 2 * * * cd /home/frappe/frappe-bench && /usr/local/bin/bench backup-all-sites >> /var/log/bench-backup.log 2>&1

Backup Workflow

The command performs the following steps for each site:
  1. Identify Sites - Lists all sites in the bench
  2. Create Backup Directory - Ensures backup directory exists
  3. Dump Database - Exports database to compressed SQL file
  4. Archive Files - Tars private files and optionally public files
  5. Backup Config - Saves site_config.json
  6. Verify - Confirms backup files were created

Comparison with Site-Specific Backup

backup-all-sites

bench backup-all-sites
  • Backs up ALL sites
  • No options available
  • Faster for multiple sites

--site backup

bench --site sitename backup
  • Backs up single site
  • Supports flags (—with-files, etc.)
  • More control per site

Site-Specific Options

For more control over individual site backups, use:
# Backup specific site with options
bench --site site1.local backup --with-files

# Backup without private files
bench --site site1.local backup --ignore-files

# Backup with compression
bench --site site1.local backup --compress

Backup Management

List Backups

# List backups for a site
ls -lh sites/site1.local/private/backups/

Delete Old Backups

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

Copy Backups Offsite

# Sync to remote server
rsync -avz ~/frappe-bench/sites/*/private/backups/ backup@remote:/backups/

# Upload to S3
aws s3 sync ~/frappe-bench/sites/site1.local/private/backups/ s3://my-bucket/backups/site1.local/

Restore from Backup

To restore a site from backup:
# Restore database
bench --site site1.local restore /path/to/backup.sql.gz

# Restore with private files
bench --site site1.local restore /path/to/backup.sql.gz --with-private-files /path/to/private-files.tar

# Restore with public files
bench --site site1.local restore /path/to/backup.sql.gz --with-public-files /path/to/public-files.tar

Implementation Details

Location: bench/commands/utils.py:137 The command calls bench.utils.system.backup_all_sites() which:
  • Iterates through all sites in the bench
  • Invokes the backup process for each site
  • Uses the same underlying backup logic as site-specific backups
  • Reports success/failure for each site

Best Practices

Set up cron jobs to run backups automatically:
  • Daily backups for production sites
  • Weekly backups for development sites
  • Before and after major updates
Don’t keep backups only on the same server:
  • Use rsync to copy to another server
  • Upload to cloud storage (S3, Google Cloud, etc.)
  • Keep at least 3 copies in different locations
Regularly test that backups can be restored:
  • Restore to a test environment monthly
  • Document restore procedures
  • Time how long restoration takes
Don’t let backups fill up disk space:
  • Keep last 7 daily backups
  • Keep last 4 weekly backups
  • Keep last 12 monthly backups
  • Delete older backups automatically

Troubleshooting

If backups are filling disk:
# Check disk usage
du -sh sites/*/private/backups/

# Clean old backups
find sites/*/private/backups -mtime +30 -delete

# Move to external storage
rsync -av --remove-source-files sites/*/private/backups/ /mnt/backup/
If you get permission denied:
# Fix ownership
sudo chown -R frappe:frappe ~/frappe-bench/sites

# Fix permissions
chmod -R 755 ~/frappe-bench/sites/*/private/backups
If database backup fails:
# Check MySQL is running
sudo service mysql status

# Test connection
bench --site site1.local console

# Check credentials in site_config.json
cat sites/site1.local/site_config.json
  • bench --site [sitename] backup - Backup a specific site with options
  • bench --site [sitename] restore - Restore a site from backup
  • bench update - Update command with automatic backup

Build docs developers (and LLMs) love