How to Safely Upgrade Nextcloud in Docker
Recently, I upgraded my Nextcloud Hub 10 (31.0.7) running in Docker to 31.0.8. The process was smooth once I followed the right steps. Here’s a summary of the procedure, including backups, upgrade commands, and fixing common warnings.
1. Backup Everything
Before upgrading, always back up your database, config, and data:
# Backup the MariaDB database
docker exec -t nextcloud-stack-db-1 mysqldump -u nextcloud -p'YOURPASSWORD' nextcloud > nextcloud_backup.sql
# Backup Nextcloud config (requires sudo because of file ownership)
sudo tar -czvf nextcloud_config_backup.tar.gz ./nextcloud_config
# Backup Nextcloud data
sudo rsync -av /mnt/nextcloud_data/ /mnt/nextcloud_data_backup/
2. Update Nextcloud Container
# Stop containers
docker-compose down
# Pull the latest Nextcloud image
docker-compose pull nextcloud
# Start containers again
docker-compose up -d
3. Run the Upgrade
Run the database migrations and app updates inside the container:
docker exec -it -u www-data nextcloud-stack-nextcloud-1 php occ upgrade
docker exec -it -u www-data nextcloud-stack-nextcloud-1 php occ status
4. Fix Warnings: Missing Indices
If you see warnings like “Detected some missing optional indices”, fix them with:
docker exec -it -u www-data nextcloud-stack-nextcloud-1 php occ db:add-missing-indices
5. Clear Nextcloud Logs
If old errors remain in the admin panel, clear logs:
# Clear logs via occ
docker exec -it -u www-data nextcloud-stack-nextcloud-1 php occ log:manage --clear
# Or truncate the log file directly
sudo truncate -s 0 /mnt/nextcloud_data/nextcloud.log
Done!
Support My Work
If this blog post helped you, please consider a small donation. Your support helps keep this content free and accessible for everyone. Thank you!
Donate with PayPal
The easiest way to support me is by buying me a coffee through PayPal. It's quick, secure, and uses a trusted platform.
Buy Me a Coffee! or a new Macbook!Donate with Crypto
You can also support me with cryptocurrency. Just copy the address of your preferred coin below.
Comments
Post a Comment