Friday, 3 June 2016

Upgrading OwnCloud 8.x to 9.x

In this blog will help out on how to upgrade the ownCloud to the latest release from a lower version (as of the writing 9.0.2) and tested from CentOS 6.7,  ownCloud 8.1.8-12.1. If using other distribution you may need to modify the path/location/command to the correct one. Some site mentioned to "Do not skip any major releases", but this work like a charms to a major leap of releases. But this was not tested on 2 major releases say 7.x to 9.x.

Steps on upgrading:

Step 1: Check the current version
rpm -qa | grep owncloud

Step 2: Backup the data and the configuration file and usually located in /var/www/html for any redhat-based distro. And turn it on maintenance mode.
cd /var/www/html/owncloud
cp -Rfp data ../data.old
cp -Rfp config ../config.old

Note: it will be copied to /var/www/html and for debian-based change -u apache to -u www-data.
Step 3. Disable the apps you enable which I think this causing the error prior to updating a major release. If login as admin in <URL>/owncloud/index.php/settings/apps?category=enabled or via command line.

cd /var/www/html/owncloud
sudo -u apache php occ app:list
sudo -u apache php occ app:enable <app-id>

Step 4. Turn on the maintenance mode.

sudo -u apache php occ maintenance:mode --off 

Step 5: Move existing repository for the ownCloud, in my case using the OpenSuse repo previously.
cd /etc/yum.repos.d/
mv isv:ownCloud:community.repo isv:ownCloud:community.repo.x


Step 6. Update the repository for ownCloud 9.x, in my case using CentOS_6 owncloud-files-9.0.2-2 on the last part from this url (a verbatim copy). As I don't want to update my php.

   Run the following shell commands as root to trust the repository.

rpm --import https://download.owncloud.org/download/repositories/stable/CentOS_6/repodata/repomd.xml.key
Run the following shell commands as root to add the repository and install from there.
wget http://download.owncloud.org/download/repositories/stable/CentOS_6/ce:stable.repo -O /etc/yum.repos.d/ce:stable.repo
yum clean expire-cache
yum install owncloud-files

Step 7: It now upgraded to latest release, check in cli "sudo -u apache php occ status". In your web browser you will be prompted to start the upgrade, but later on you will encounter an error like:
Exception: Updates between multiple major versions and downgrades are unsupported.Update failed
In the command line:


sudo -u apache php occ upgrade
ownCloud 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
Set log level to debug
Turned on maintenance mode
Exception: Updates between multiple major versions and downgrades are unsupported.
Update failed
Maintenance mode is kept active
Reset log level

Step 8: Modify the configuration file and change it to the correct version.

sudo -u apache php occ status
  - installed: true
  - version: 9.0.2.2
  - versionstring: 9.0.2
  - edition: 



vi config/config.php
    #change the version from 8.1.8.2
    'version' => '8.1.8.2',
    to     
    # version 9.0.2
'version' => '9.0.2.2',


then save and exit.

Step 9: Do step 7, or use your browser to upgrade and turn off the maintenance mode.
sudo -u apache php occ maintenance:mode --off 


Step 10: You have to enable back those disable apps in step 3, it need one at a time - no shortcut. Example (your apps may differ to mine).






Step 11: Viola! you have now updated your owncloud to the latest version. But if you wanted to get rid of the annoying Security & setup warnings.


Security & setup warnings• The "Strict-Transport-Security" HTTP header is not configured to at least "15768000" seconds. For enhanced security we recommend enabling HSTS as described in our security tips.• No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.Please double check the installation guides ↗, and check for any errors or warnings in the log.

Do these further steps:
a. Install memcache and check if running.


yum install memcached
ps ax | grep memcached

b. Modify the config.php, to include memcache settings, after any comma (,) 
vi config/config.php

'memcache.local' => '\OC\Memcache\APCu', 'memcache.distributed' => '\OC\Memcache\Memcached', 'memcached_servers' => array( array('localhost', 11211), array('mabco.panganod.org', 11211), ), 
c. For Strict-Transport-Security, edit the ssl.conf of your apache. Restart your web server.
vi /etc/httpd/conf.d/ssl.conf

#put these line before </VirtualHost>, as seen at the bottom.
    <IfModule mod_headers.c>
     Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
    </IfModule>

</VirtualHost>

#save and exit.

service httpd restart
Hope this may help on your issue with upgrading the ownCloud to the latest release.

Note:
I am not responsible for any loss of your data if something gonna wrong for following this guide. Backup is highly recommended prior to do those steps.




References:
https://doc.owncloud.org/server/9.0/admin_manual/maintenance/upgrade.html
https://forum.owncloud.org/viewtopic.php?t=33569
https://doc.owncloud.org/server/9.0/admin_manual/installation/linux_installation.html#repos-stable-or-version
https://doc.owncloud.org/server/8.2/admin_manual/configuration_files/encryption_configuration.html#upgrading-encryption-label
https://doc.owncloud.org/server/8.0/admin_manual/configuration_server/harden_server.html
https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/security_setup_warnings.html



No comments:

Post a Comment