create your docker-compose file like this one:
version: '3'
volumes:
nextcloud:
db:
services:
db:
image: mariadb:10.8.2
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: unless-stopped
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=YOUR_PASS
- MYSQL_PASSWORD=YOUR_PASS2
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
image: nextcloud:26.0.0
environment:
- OBJECTSTORE_S3_SSL=true
- OBJECTSTORE_S3_USEPATH_STYLE=true
- OBJECTSTORE_S3_BUCKET=BUCKET-NAME
- OBJECTSTORE_S3_KEY=BUCKET-KEY
- OBJECTSTORE_S3_SECRET=BUCKET-SECRET
- OBJECTSTORE_S3_REGION=YOUR_REGION
- OBJECTSTORE_S3_HOST=YOUR_HOST
- OBJECTSTORE_S3_PORT=443
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html
restart: unless-stopped
In my case I'm using the DigitalOcean Spaces services (similar to Amazon S3)
now probably you have a nextcloud running in an old version. So I recommend you to backup the whole Nextcloud files.
Log into the nextcloud_app container
docker exec -u www-data -it nextcloud_app_1 /bin/bash
tar -zcvf nextcloud_backup_YYYYMMDD.tgz /var/www/html/
Do the same with the database
docker exec -it nextcloud_db_1 /bin/bash
mysqldump -u nextcloud -p nextcloud > nextcloud_backup_YYYYMMDD.sql
logout and copy the backups files to a save place
docker cp nextcloud_app_1:/var/www/nextcloud_backup_YYYYMMDD.tgz ./
docker cp nextcloud_db_1:/nextcloud_backup_YYYYMMDD.sql ./
now you can remove your nextcloud containers and volumes. Make sure that you have the backup of your volume. I didn't create the backup of my volume because it is hosted on DigitalOcean.
docker rm nextcloud_app_1 nextcloud_db_1
docker volume rm nextcloud_nextcloud nextcloud_db
Pull a new image of nextcloud and rebuild the docker images
docker-compose pull
docker-compose up -d
copy the backup file to the new containers
docker cp nextcloud_backup_YYYYMMDD.tgz nextcloud_app_1:/var/www/
docker cp ./nextcloud_backup_YYYYMMDD.sql nextcloud_db_1:/
Go to nextcloud app container untar the backup file, copy the data and config folders to /var/www/html
docker exec -u www-data -it nextcloud_db_1 /bin/bash
tar -zxvf nextcloud_backup_YYYYMMDD.tgz
cd html
mv data data-new && mv config config-new
cp -Rp ../nextcloud_backup_YYYYMMDD/config ./ && cp -Rp ../nextcloud_backup_YYYYMMDD/data
Restore the old database:
docker exec -u www-data -it nextcloud_app_1 /bin/bash
mysql -u nextcloud -p nextcloud < ./nextcloud_backup_YYYYMMDD.sql
Now here comes the trick part. The nextcloud DB and config/data files are using the old version but the
source code is in the new version. So, if you try to upgrade the nextcloud using php occ upgrade
it will not work and
you will get an error like this one.
www-data@0e70a33a757f:~/html$ php occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Exception: Updates between multiple major versions and downgrades are unsupported.
Update failed
Maintenance mode is kept active
Resetting log level
There is a work around where you can edit the lib/private/Updater.php
file to bypass this verification and perform
the upgrade.
Edit lines 217 and 225 and add the returning true
values.
if ($currentVendor === 'nextcloud') {
return true;
return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
&& (version_compare($oldVersion, $newVersion, '<=') ||
$this->config->getSystemValue('debug', false));
}
// Check if the instance can be migrated
return true;
return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
save the file and run the upgrade
php occ upgrade
This will work fine, now just turn off the maintenance mode
php occ maintenance:mode --off
Remove the true
returns in the Updater.php file
if ($currentVendor === 'nextcloud') {
return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
&& (version_compare($oldVersion, $newVersion, '<=') ||
$this->config->getSystemValue('debug', false));
}
// Check if the instance can be migrated
return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
Done. Probabably everything will works.
Stop your nextcloud app container, only the app. Remove the container (yes, do it), pull the new image and build the image.
$ docker stop nextcloud_app_1
$ docker rm nextcloud_app_1
$ docker-compose pull
$ docker-compose up -d
NOTE: I strongly recommend you backup your data files and DB data before it.
php occ files:scan --all
just install the libmagick core
docker-compose exec app apt -y install libmagickcore-6.q16-6-extra