How to update Joomla safely from the command line (core and extensions)
Joomla core and extension vulnerabilities are exploited quickly after disclosure. Joomla 4 and 5 include a command-line tool that checks and applies updates, which is faster and easier to repeat than the admin screen.
Back up first
Database and files, outside the web root.
cd /path/to/joomla mysqldump DBNAME > ~/joomla-$(date +%F).sql tar czf ~/joomla-files-$(date +%F).tgz .Check the version and updates
The CLI is run as the site user.
sudo -u SITEUSER php cli/joomla.php core:check-updatesTake the site offline
So nobody uses it during the update.
sudo -u SITEUSER php cli/joomla.php site:downUpdate core
Run it and read the output for errors.
sudo -u SITEUSER php cli/joomla.php core:updateUpdate extensions and templates
Use the admin Extensions, Update screen: the CLI updates core only. Update everything that has a security release.
Bring the site back and verify
Clear caches and test login, forms and key pages.
sudo -u SITEUSER php cli/joomla.php site:up sudo -u SITEUSER php cli/joomla.php cache:clean
Common mistakes
- Updating on a PHP version Joomla does not support yet.
- Third-party extensions that lag behind core: check each one first.
- Working as root and changing file ownership.
How to undo it
Restore the database dump and the files archive.
Sources
Commands are for Debian and Ubuntu unless noted. Test on a copy first and keep a backup: you are responsible for changes on your own systems.