Upgrading OwnCloud (or, keep up to date to avoid issues)

It turns out that OwnCloud is a finicky piece of software. After being defeated in my attempts to update, I grew determined to win.

Premise:

We have a CentOS 6 x64 server running OC, v7.0.2. Current release is 9.0.1, but OC doesn’t support direct upgrades between major versions, and it wasn’t even as simple as 7.0 to 8.0 to 9.0 — there was an 8.1 and an 8.2 in there as well.

OC was originally installed via an OpenSUSE package. That package has since gone out of date and no upgrade path via that method existed.

(note, backup your system here)

Step 1: Update 7.0.2 to 7.0.11

Step 1 was probably the easiest.

Download the 7.0.11 tar.bz2 from the change page (https://owncloud.org/changelog/), drop in the DocRoot.

Move the old owncloud directory out of the way, unpackage the new one, and copy the config.php (ownclloud-old/config/config.php) into the new directory (owncloud/config/).

Hit the webpage, follow the upgrade steps. Owncloud handles the DB changes and makes sure everything is happy.

Once the upgrade is done, log in and make sure all is well.

(note, backup your system here)

Step 2: Update 7.0.11 to 8.0.9

This is where the fun starts. I’m working on a CentOS 6 box, and the packaged version of PHP for Cent6 is 5.3 (5.3.3, to be exact). As it happens, 8.0 requires PHP 5.4, so life just got interesting.

A few commands, and we’re away:

yum install centos-release-SCL
yum install php54 php54-php php54-php-gd php54-php-mbstring php54-php-mysqlnd
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.off
service httpd restart

Actually, at this point, you’re best off stopping HTTPd, unless you have a very small OwnCloud instance. The OC forums are riddled with comments and notes about how long this next step took, and by default it will time out after 3600s, or one hour in a browser window.

Download the 8.0.9 tar.bz from the change page (above), drop in the DocRoot.

Move the old owncloud directory out of the way, unpackage the new one, and copy the config.php (ownclloud-old/config/config.php) into the new directory (owncloud/config/).

Move into your new OwnCloud directory and run:

sudo -u apache /opt/rh/php54/root/usr/bin/php occ upgrade

This runs the upgrade script that would be run from your browser, but instead does it from command line. It also uses the PHP5.4 binary, and runs as the Apache user (in CentOS). No worries about timeouts!

This step takes a long time. Apparently it has to do with rewriting all of the encryption keys for every file uploaded to your cloud. ‘top’ showed 100% CPU usage for the duration, I left it overnight to run and with our 50GB of data it took about 3 hours.

Once that’s done, migrate the encryption keys:

sudo -u apache /opt/rh/php54/root/usr/bin/php occ encryption:migrate

Restart httpd (if you stopped it) and log in. Make sure all is well.

(note, backup your system here)

Step 3: Update 8.0.9 to 8.1.4

This is essentially the same as Step 2, without a PHP upgrade.

Move the old owncloud directory out of the way, unpackage the new one, and copy the config.php (ownclloud-old/config/config.php) into the new directory (owncloud/config/).

Move into your new OwnCloud directory and run:

sudo -u apache /opt/rh/php54/root/usr/bin/php occ upgrade

For me, this step was much faster, taking only two minutes.

Restart httpd (if you stopped it) and log in. Make sure all is well.

(note, backup your system here)

Step 4: Update 8.1.4 to 8.2.1

Again, essentially the same.

Move the old owncloud directory out of the way, unpackage the new one, and copy the config.php (ownclloud-old/config/config.php) into the new directory (owncloud/config/).

Move into your new OwnCloud directory and run:

sudo -u apache /opt/rh/php54/root/usr/bin/php occ upgrade

This took a little longer, mostly hanging on the database schema update check. And by a little longer, I mean about 90 seconds.

Log in once more and check that all is well.

(note, backup your system here)

Step 5: Update 8.2.1 to 9.0.1

Not so simple this time, although you could do it the same way. We wanted to get back onto the point releases, so we moved back to using packages.

Move the owncloud directory out of the way, and remove the owncloud package (7.0.2) from the system.

Remove the old repos, and install the updated ones:

rpm --import https://download.owncloud.org/download/repositories/stable/CentOS_6_SCL_PHP54/repodata/repomd.xml.key
wget http://download.owncloud.org/download/repositories/stable/CentOS_6_SCL_PHP54/ce:stable.repo -O /etc/yum.repos.d/ce:stable.repo
yum clean expire-cache
yum install owncloud-files

Copy the config into the appropriate directory, switch to the OwnCloud directory and run, once more:

sudo -u apache /opt/rh/php54/root/usr/bin/php occ upgrade

Log in and check all is well.

For kicks, back up your system one last time.

You’re now running the latest available OwnCloud, installed from package. Now you just need to keep that up to date, and life will be significantly easier!

Now I can run a yum update again, and not have to see cascading dependency failures, or risk breaking the system because the package available is too far ahead of what was installed.

Leave a Reply