Skip to main content

Overview

The bench update command performs a comprehensive update operation on your bench. By default, it backs up sites, pulls updates for all apps, updates requirements, builds assets, runs database migrations, and restarts services. You can use specific flags to perform only certain tasks.

Syntax

bench update [OPTIONS]

Options

--pull
boolean
default:"false"
Pull the latest updates from Git repositories for all apps in the bench.
bench update --pull
--apps
string
default:"None"
Specify which apps to update. Provide a comma-separated list of app names.
bench update --apps frappe,erpnext
--patch
boolean
default:"false"
Run database migrations for all sites in the bench.
bench update --patch
--build
boolean
default:"false"
Build JavaScript and CSS assets for the bench.
bench update --build
--requirements
boolean
default:"false"
Update Python and Node.js dependencies. If run alone, equivalent to bench setup requirements.
bench update --requirements
--restart-supervisor
boolean
default:"false"
Restart Supervisor processes after the update completes.
bench update --restart-supervisor
--restart-systemd
boolean
default:"false"
Restart systemd units after the update completes.
bench update --restart-systemd
--no-backup
boolean
default:"false"
Skip backing up sites before performing updates.
Using --no-backup in production is not recommended. Always backup before updates.
bench update --no-backup
--force
boolean
default:"false"
Force major version upgrades. Use this when upgrading to a new major version of Frappe or ERPNext.
bench update --force
--reset
boolean
default:"false"
Hard reset Git branches to their remote states, overriding any local changes and conflicts. This is equivalent to git reset --hard origin/branch.
Using --reset will discard all local changes. Commit or stash changes before using this flag.
bench update --reset
--no-compile
boolean
default:"false"
[DEPRECATED] This flag no longer has any effect and is kept for backward compatibility.

Usage Examples

Full Update (Default)

Perform a complete update with all operations:
bench update
This executes:
  1. Backup all sites
  2. Pull updates for all apps
  3. Update requirements
  4. Run database migrations
  5. Build assets
  6. Restart services

Update Specific Apps

Update only Frappe and ERPNext:
bench update --apps frappe,erpnext

Pull Updates Only

Just pull the latest code without building or migrating:
bench update --pull

Build Assets Only

Rebuild front-end assets without pulling code:
bench update --build

Run Migrations Only

Execute database patches without other operations:
bench update --patch

Update Requirements Only

Install updated Python and Node.js dependencies:
bench update --requirements

Quick Development Update

Update without backup (development only):
bench update --no-backup

Force Major Version Upgrade

Upgrade to a new major version:
bench update --force

Reset to Remote State

Discard local changes and sync with remote:
bench update --reset

Production Update with Supervisor

Update and restart production services:
sudo bench update --restart-supervisor

What Happens During Update

1. Backup (unless —no-backup)

Backing up sites...
Backed up site1.local
Backed up site2.local

2. Pull Updates (unless specific flags)

Updating frappe...
Updating erpnext...
Updating hrms...

3. Update Requirements

Installing Python dependencies...
Installing Node.js dependencies...

4. Migrate Sites

Migrating site1.local...
Executing patches...
Migration complete

5. Build Assets

Building assets...
Building frappe...
Building erpnext...
Assets built successfully

6. Restart Services

Restarting processes...

Common Patterns

Safe Production Update

Recommended approach for production environments:
# 1. Take manual backup first
bench backup-all-sites

# 2. Update in maintenance mode
bench --site all set-maintenance-mode on

# 3. Perform update
sudo bench update --restart-supervisor

# 4. Verify everything works

# 5. Disable maintenance mode
bench --site all set-maintenance-mode off

Development Quick Update

Fast update during development:
bench update --no-backup --build

Update After Code Changes

When you’ve made changes to app code:
bench update --patch --build

Fix Broken Update

If an update fails or causes issues:
# Reset to last working state
bench update --reset

# Or restore from backup
bench restore site1.local --database path/to/database.sql.gz

Version Control Behavior

Normal Update (git pull —rebase)

By default, bench update --pull attempts to rebase local commits:
git pull --rebase origin branch

Reset Mode (git reset —hard)

With --reset, local changes are discarded:
git fetch origin
git reset --hard origin/branch

Updating to Specific Versions

To update to a specific Frappe or ERPNext version:
# Switch to version branch
bench switch-to-branch version-15 frappe erpnext

# Update with force flag
bench update --force

Troubleshooting

Update Fails with Merge Conflicts

Reset to remote state:
bench update --reset
Or resolve conflicts manually:
cd apps/frappe
git status
git merge --abort
git stash
bench update

Migration Errors

If migrations fail:
# Check which patch failed
bench migrate

# Skip problematic patches (not recommended)
bench --site site1.local migrate --skip-failing

Asset Build Failures

Rebuild with verbose output:
bench build --force --verbose
Clear cache and rebuild:
bench clear-cache
bench build

Requirements Installation Issues

Manually update requirements:
bench setup requirements --python
bench setup requirements --node

Performance Considerations

Large Benches

For benches with many apps or sites:
# Update specific apps
bench update --apps critical_app

# Skip asset build temporarily
bench update --no-backup --pull --patch
bench build  # Build separately when ready

Reducing Downtime

Minimize production downtime:
# Pull and build without restarting
bench update --pull --build --no-backup

# Migrate during maintenance window
bench --site all set-maintenance-mode on
bench migrate
sudo supervisorctl restart all
bench --site all set-maintenance-mode off

Automated Updates

Set up automatic updates (use with caution):
# Create a cron job
crontab -e

# Add entry for weekly updates
0 2 * * 0 cd /home/frappe/frappe-bench && /usr/local/bin/bench update --no-backup >> /var/log/bench-update.log 2>&1
Automated updates in production should be thoroughly tested and monitored. Always have a rollback plan.

Build docs developers (and LLMs) love