Backups are critical for any production ERPNext instance. Losing your ERP data means losing invoices, inventory records, and customer information. This guide shows you how to set up automated daily backups with offsite storage.
STEP 1 Manual Backup (Understanding the Basics)
cd frappe-bench
bench --site mysite.local backupThis creates three files in the sites/mysite.local/private/backups directory:
# Database backup
20260410_120000-mysite_local-database.sql.gz
# Files backup (uploaded documents)
20260410_120000-mysite_local-files.tar
# Private files backup
20260410_120000-mysite_local-private-files.tarSTEP 2 Backup With File Uploads
bench --site mysite.local backup --with-filesSTEP 3 Create a Backup Script
nano /home/erpnext/backup.sh#!/bin/bash
BENCH_DIR="/home/erpnext/frappe-bench"
SITE="mysite.local"
BACKUP_DIR="/home/erpnext/backups"
DATE=$(date +%Y%m%d)
cd $BENCH_DIR
bench --site $SITE backup --with-files
# Copy to backup directory
mkdir -p $BACKUP_DIR/$DATE
cp sites/$SITE/private/backups/*$DATE* $BACKUP_DIR/$DATE/
# Delete backups older than 30 days
find $BACKUP_DIR -type d -mtime +30 -exec rm -rf {} +
echo "Backup completed: $DATE"chmod +x /home/erpnext/backup.shSTEP 4 Schedule With Cron
crontab -eAdd this line to run the backup every day at 2 AM:
0 2 * * * /home/erpnext/backup.sh >> /home/erpnext/backup.log 2>&1STEP 5 Upload to S3 (Offsite Backup)
sudo apt install -y awscli
aws configureAdd this to your backup script:
aws s3 sync $BACKUP_DIR/$DATE s3://your-bucket-name/erpnext-backups/$DATE/STEP 6 Restore From Backup
bench --site mysite.local restore
/path/to/database-backup.sql.gz
--with-private-files /path/to/private-files.tar
--with-public-files /path/to/files.tarTest your restore process at least once a month. A backup you can’t restore from is not a backup — it’s just a file taking up disk space.
Comments
Join the discussion. Got a question, found an issue, or want to share your experience?