$npx -y skills add Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-ops-backupUse when configuring backups, restoring sites, encrypting backup files, scheduling automated backups, or planning disaster recovery. Prevents data loss from missing backups, failed restores, and unencrypted sensitive data. Covers bench backup, bench restore, backup encryption, S3
| 1 | # Backup & Disaster Recovery |
| 2 | |
| 3 | Frappe provides built-in backup and restore commands via bench. ALWAYS back up before updates, migrations, or any destructive operation. A backup that has never been test-restored is NOT a backup. |
| 4 | |
| 5 | ## Quick Reference |
| 6 | |
| 7 | ```bash |
| 8 | # Database-only backup (default) |
| 9 | bench backup |
| 10 | |
| 11 | # Full backup with public + private files |
| 12 | bench backup --with-files |
| 13 | |
| 14 | # Backup specific site |
| 15 | bench --site mysite.com backup --with-files |
| 16 | |
| 17 | # Backup with compression (.tgz instead of .tar) |
| 18 | bench backup --with-files --compress |
| 19 | |
| 20 | # Backup only specific DocTypes |
| 21 | bench backup --only "Sales Invoice,Purchase Invoice" |
| 22 | |
| 23 | # Backup excluding specific DocTypes |
| 24 | bench backup --exclude "Error Log,Activity Log" |
| 25 | |
| 26 | # Custom backup path |
| 27 | bench backup --backup-path /mnt/backups/ |
| 28 | |
| 29 | # Restore from backup |
| 30 | bench --site mysite.com restore /path/to/backup.sql.gz |
| 31 | |
| 32 | # Restore with files |
| 33 | bench --site mysite.com restore /path/to/backup.sql.gz \ |
| 34 | --with-public-files /path/to/files.tar \ |
| 35 | --with-private-files /path/to/private-files.tar |
| 36 | |
| 37 | # Setup automated backups (cron) |
| 38 | bench setup backups |
| 39 | ``` |
| 40 | |
| 41 | ### What Gets Backed Up |
| 42 | |
| 43 | | Component | Default | With --with-files | Location | |
| 44 | |---|---|---|---| |
| 45 | | Database (SQL dump) | YES | YES | `sites/{site}/private/backups/` | |
| 46 | | Site config | YES | YES | `sites/{site}/private/backups/` | |
| 47 | | Public files | NO | YES | `sites/{site}/public/files/` | |
| 48 | | Private files | NO | YES | `sites/{site}/private/files/` | |
| 49 | |
| 50 | **Backup file naming**: `{datetime}_{hash}_{site}-database.sql.gz` |
| 51 | |
| 52 | --- |
| 53 | |
| 54 | ## Backup Decision Tree |
| 55 | |
| 56 | ``` |
| 57 | What do you need to back up? |
| 58 | | |
| 59 | +-- Quick database snapshot before a change? |
| 60 | | +-- bench backup (database only, fast) |
| 61 | | |
| 62 | +-- Full backup before upgrade or migration? |
| 63 | | +-- bench backup --with-files --compress |
| 64 | | |
| 65 | +-- Automated daily backups? |
| 66 | | +-- bench setup backups (cron-based) |
| 67 | | +-- OR S3 Backup Settings (cloud storage) |
| 68 | | |
| 69 | +-- Offsite / cloud backup? |
| 70 | | +-- S3 Backup Settings DocType (built-in) |
| 71 | | +-- OR custom script with rclone/aws-cli |
| 72 | | |
| 73 | +-- Partial backup (specific DocTypes)? |
| 74 | | +-- bench backup --only "DocType1,DocType2" |
| 75 | | |
| 76 | +-- Disaster recovery? |
| 77 | | +-- Full backup + files + tested restore procedure |
| 78 | | +-- See Disaster Recovery section below |
| 79 | ``` |
| 80 | |
| 81 | --- |
| 82 | |
| 83 | ## bench backup: All Options |
| 84 | |
| 85 | ```bash |
| 86 | bench backup [OPTIONS] |
| 87 | |
| 88 | # Path options |
| 89 | --backup-path PATH # Save all backup files to this directory |
| 90 | --backup-path-db PATH # Custom path for database dump |
| 91 | --backup-path-conf PATH # Custom path for site config backup |
| 92 | --backup-path-files PATH # Custom path for public files archive |
| 93 | --backup-path-private-files PATH # Custom path for private files archive |
| 94 | |
| 95 | # Filter options |
| 96 | --only, --include, -i DOCTYPES # Include ONLY these DocTypes (comma-separated) |
| 97 | --exclude, -e DOCTYPES # Exclude these DocTypes (comma-separated) |
| 98 | --ignore-backup-conf # Ignore include/exclude from site config |
| 99 | |
| 100 | # Flags |
| 101 | --with-files # Include public and private files |
| 102 | --compress # Use .tgz format (gzip compressed tar) |
| 103 | --verbose # Show detailed output |
| 104 | ``` |
| 105 | |
| 106 | **Safety feature**: If backup fails (any exception), partial files are automatically deleted to avoid consuming disk space with incomplete backups. |
| 107 | |
| 108 | --- |
| 109 | |
| 110 | ## bench restore: All Options |
| 111 | |
| 112 | ```bash |
| 113 | bench --site [site-name] restore [OPTIONS] SQL_FILE_PATH |
| 114 | |
| 115 | # SQL_FILE_PATH: path to .sql or .sql.gz file |
| 116 | # Can be relative to sites/ directory or absolute path |
| 117 | |
| 118 | # Options |
| 119 | --db-root-username USERNAME # MariaDB/PostgreSQL root username |
| 120 | --db-root-password PASSWORD # MariaDB/PostgreSQL root password |
| 121 | --db-name NAME # Use custom database name |
| 122 | --admin-password PASSWORD # Set administrator password after restore |
| 123 | --install-app APP_NAME # Install app after restore |
| 124 | --with-public-files PATH # Restore public files (.tar or .tgz) |
| 125 | --with-private-files PATH # Restore private files (.tar or .tgz) |
| 126 | |
| 127 | # Flags |
| 128 | --force # Bypass downgrade warnings (NOT recommended) |
| 129 | ``` |
| 130 | |
| 131 | **CRITICAL**: Downgrades are NOT supported. Restoring a backup from a newer version onto an older version triggers a warning. NEVER use `--force` to bypass this unless you understand the consequences. |
| 132 | |
| 133 | --- |
| 134 | |
| 135 | ## Automated Backups |
| 136 | |
| 137 | ### Cron-Based (bench s |