How to – Upgrade Nextcloud
Yet another Nextcloud blog post, yearh. I have to admit I am out of inspiration wen it comes to get new ideas for new posts at the time. But then again it is good that Nextcloud is fairly new and there is a lot to cover on that front.
In this post will I show you how to perform an easy manual upgrade there should be a lot safer than using the package manager, I was speaking with some of the nextcloud developers last month where they said they wouldn’t create repos for nextcloud but it appears somebody have created a repo if you take a look here. For your own sake and safety please do NOT use these repositories a use a few minitues of your life to do the upgrade manually it isn’t that hard and you will not have to fight the repos! I’ve had multiple issues with the old Owncloud repo earlier and it isn’t worth it.
As a start we will put nextcloud in manitaince mode to make sure the is no user interference (I will do everything as root-user)
1 2 3 | cd /var/www/nextcloud sudo -u www-data php occ maintenance:mode --on |
The next thing is to create a backup of the current nextcloud installation you have
1 2 3 | cd .. cp -r nextcloud/ nextcloud.old/ |
Then download the latest version of nextcloud and make sure to change the wget cmd.
1 2 3 | cd /tmp/ wget https://download.nextcloud.com/server/releases/nextcloud-9.0.52.tar.bz2 |
unpack the tarball with
1 2 | tar xjf nextcloud<version nr>.tar.bz2 |
then copy everything from the new nextcloud folder to your current nextcloud installation in /var/www (make sure to copy the hidden files)
1 2 3 4 | cd nextcloud cp -r * /var/www/nextcloud/ cp -r .* /var/www/nextcloud |
then we will need to moove the old config/ and data/ direcories back again
1 2 3 | cp -r /var/www/nextcloud.old/config/ /var/www/nextcloud/ cp -r /var/www/nextcloud.old/data/ /var/www/nextcloud/ |
make sure your nextcloud folder & files have the right permissions.
you can use this script to automaticly set the permissions just save the code below to a file and give it permissions to execute with chmod +x permission_file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #!/bin/bash ocpath='/var/www/nextcloud' htuser='www-data' htgroup='www-data' rootuser='root' printf "Creating possible missing Directories\n" mkdir -p $ocpath/data mkdir -p $ocpath/assets mkdir -p $ocpath/updater printf "chmod Files and Directories\n" find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640 find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750 printf "chown Directories\n" chown -R ${rootuser}:${htgroup} ${ocpath}/ chown -R ${htuser}:${htgroup} ${ocpath}/apps/ chown -R ${htuser}:${htgroup} ${ocpath}/assets/ chown -R ${htuser}:${htgroup} ${ocpath}/config/ chown -R ${htuser}:${htgroup} ${ocpath}/data/ chown -R ${htuser}:${htgroup} ${ocpath}/themes/ chown -R ${htuser}:${htgroup} ${ocpath}/updater/ chmod +x ${ocpath}/occ printf "chmod/chown .htaccess\n" if [ -f ${ocpath}/.htaccess ] then chmod 0644 ${ocpath}/.htaccess chown ${rootuser}:${htgroup} ${ocpath}/.htaccess fi if [ -f ${ocpath}/data/.htaccess ] then chmod 0644 ${ocpath}/data/.htaccess chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess fi |
then go to you installation folder and perform the actual upgrade and exit maintenance mode.
1 2 3 4 | cd /var/www/nextcloud sudo -u www-data php occ upgrade sudo -u www-data php occ maintenance:mode --off |
Fell free to contact me if you have any troubles or thought regarding the post or anything else.