Backup and Upgrade Nextcloud from 13.0.0 to 14.0.1 - Notes


Backup Prior to Updating

Enable Maintenance Mode

Navigate to the nextcloud directory and enable maintenance mode:

sudo -u www-data php occ maintenance:mode --on

Backup Filesystem

sudo rsync -Aax /var/www/nextcloud/ ~/nextcloud-dirbkp_`date +"%Y%m%d"`

Backup Database

mysqldump --single-transaction -u user -p nextcloud > ~/nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

Upgrade Using the updater.phar Package

From the upgrade docs:

Instead of clicking that button you can now invoke the command line based updater by going into the updater/ directory in the Nextcloud directory and executing the updater.phar as the web server user.

https://docs.nextcloud.com/server/13/admin_manual/maintenance/update.html#using-the-command-line-based-updater

Error due to Presence of Let's Encrypt .well-known Directory

The Nextcloud CLI updater.phar routine does not like the presence of Let's Encrypt's .well-known directory. A simple strategy is to just move it out of the web root for the duration of the upgrade, and restoring it to it's original location when done. Alternatively it would be feasible to serve the .well-known directory from a different path via a web server config.

sudo -u www-data php updater.phar
Nextcloud Updater - version: v13.0.0beta1

Current version is 13.0.0.

Update to Nextcloud 14.0.1 available. (channel: "stable")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-14.0.1.zip

[...]

Start update? [y/N] y

Info: Pressing Ctrl-C will finish the currently running step and then stops the updater.

[✘] Check for expected files failed
The following extra files have been found:
    .well-known

Update failed. To resume or retry just execute the updater again.

The update went off without a hitch after temporarily moving the .well-known directory from the Nextcloud root:

sudo -u www-data php updater/updater.phar

[...]

Maintenance mode is disabled

occ Commands

Turn off maintenance mode

sudo -u www-data php occ maintenance:mode --off

Add Missing Database indices

Sometimes when updating various table indexes are skipped, this will add them after an update.

occ db:add-missing-indices

Convert Various Database Tables to big-int Data Type

sudo -u www-data php occ db:convert-filecache-bigint

Further Upgrades

Version Nextcloud 14.0.1 to Nextcloud 14.0.3

Missing Indexes

The following message appeared in the admin dashboard:

The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running "occ db:add-missing-indices" those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.

    Missing index "share_with_index" in table "oc_share".
    Missing index "parent_index" in table "oc_share".
    Missing index "fs_mtime" in table "oc_filecache".

I added the indices with the following command:

sudo -u www-data php occ db:add-missing-indices
Check indices of the share table.
Adding additional share_with index to the share table, this can take some time...
Share table updated successfully.
Adding additional parent index to the share table, this can take some time...
Share table updated successfully.
Adding additional mtime index to the filecache table, this can take some time...
Filecache table updated successfully.

Version Nextcloud 14.0.3 to Nextcloud 15.0.0

Ran into the missing indexes problem again during this update, and used the occ db:add-missing-indices command to add them manually.

Recommendation to Install PHP Module imagick

sudo apt install php-imagick

Database Fields Missing Conversion to big int

Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running 'occ db:convert-filecache-bigint' those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read the documentation page about this.

activity.activity_id
activity.object_id
activity_mq.mail_id
filecache.fileid
filecache.storage
filecache.parent
filecache.mimetype
filecache.mimepart
filecache.mtime
filecache.storage_mtime
mimetypes.id
storages.numeric_id
sudo -u www-data php occ db:convert-filecache-bigint
Following columns will be updated:

This can take up to hours, depending on the number of files in your instance!
Continue with the conversion (y/n)? [n] y

Update Version of intl PHP Module

Encountered the following errors in the log, having to do with a missing php intl extension:

You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead. at /var/www/nextcloud/3rdparty/patchwork/utf8/src/Patchwork/Utf8/Bootup/intl.php#18

Search for the module and install it:

apt search php-intl
Sorting... Done
Full Text Search... Done
php-intl/xenial-updates 1:7.0+35ubuntu6.1 all
  Internationalisation module for PHP [default]

Helpful Links and Misc. Info


Tags:  Nextcloud

Comments:


Gravatar of Kyle Jones

Knowledge Base is a repository for various notes, guides, and thoughts on a wide range of IT related topics. Read more...

Sponsored By:


Web development services by Say Web Solutions. Visit website.