Synced files seem corrupted after upgrade to owncloud 5 version

I just upgraded my owncloud community version from 4.5.7-1 to 5.0.3 with the effect, that I can’t read any of my files in the sync folder anymore! All seem to be corrupted. If you have the same problem, continue reading and find out how to solve it.

Short Story

Currently there’s an undocumented issue when upgrading from a 4.x to 5.x version with an enabled encryption plugin. Since this plugin isn’t ported to the 5.x version yet, encrypted files can’t be read/decrypted anymore and – even worse – are synced encrypted to the client – overwriting all existing (working) files! So you end up with “corrupted” files on the server and on all clients syncing with it! My current advice: don’t upgrade owncloud 4 to 5 with activated encryption plugin (yet)!

As stated in the response to this issue, the suggestion is to backup all files and the database and to downgrade owncloud to the previous version – or – to wait (lol) for the new encryption plugin to become available.

Whether the first option really works out, I can’t tell due to another package-related issue (read about it on the Long Story). Lucky me, I had a backup of the old database and the complete owncloud directory. So I restored both and went back to the 4.5.7 version. After that, all “corrupted” files were restored successfully on the clients after the next sync. So for now, everything is back to normal – at least for me. I feel sorry for all the other poor guys that won’t have a backup or can’t rollback to the previous version for other reasons.

As much I thank owncloud for its free and open-source synchronization software, this is really a no-go issue! I’m a software developer as well, and IMHO updating a software should never corrupt or delete any (user) data! For me, this is a worst-case scenario. Such an issue must be highlighted in the documentation and must not happen during an update process! Better abort/refuse the installation and inform the user about the reason. I can’t really understand why such a thing must even be discussed – that is a standard scenario.

I updated many Linux distributions and packages over the last years without any such issue. But updating owncloud via apt-get today was a big blooper.

Long Story

Normally I try to avoid .0 releases and try to ‘never touch a running system’. But today, I felt brave and thought upgrading my 4.5.7 owncloud version to the shiny 5.0.3 would be a good idea. Since some of the major bugs were already fixed, I wanted to give it a try. So I invoked

apt-get install owncloud

and it completed without any errors. After that I went to the webfrontend to trigger the owncloud internal update. This failed with

Updating ownCloud to version 5.0.3, this may take a while.
Turned on maintenance mode
Updated database
SQLSTATE[42703]: Undefined column: 7 ERROR: column "{DAV:}getetag" does not exist LINE 1:" = $1 AND propertypath = $2 AND propertyname = "{DAV:}get... ^

After finding the related bug report on google, I fixed the bug manually as described there and reloaded the page. This time the update went through without errors. That’s ok – shit happens.

Then I updated my Windows owncloud client to 1.2.3 and it started syncing immediately. After 5 minutes it told me that it deleted (!) one specific file and 50 others. WTF?! I got a little nervous and started checking my files locally. But apparently all files were there and the size didn’t give me any reason to panic. Oh, silly me. Since I was still suspicious, I simply doubleclicked a pdf file in my shared folder. “This file can’t be opened because it might be corrupted…”. WTF?! I tried other files in the sync folder – all files were corrupted – or so I thought. Now I know, that these files are encrypted because of the missing encryption plugin on the server side. But still: the local files are unusable!

Then, I remembered that it maybe has todo with the encryption plugin that I had enabled all the time and tried a google search on it. I stumbled over another bug report that related to the encryption functionality and faced the ugly truth. Downgrading or waiting for the encryption plugin to be ported to the 5.x release. Waiting? Seriously? Actually having all files in an unusable state for an unknown period of time isn’t a situation I’m keen on.

So downgrading was the only option for me. Since I’m using the Ubuntu package, I removed the 5.0.3 version and tried to install 4.5.7-1 again. But it seems, that this package isn’t available anymore. Luckily I had my nightly backup of the owncloud database and directory so I could restore the old version. Although the Ubuntu package itself is still missing, it seems to work.

I’ve sent an email to the package maintainer asking whether there’s the old version somewhere available. I’ll keep you posted…