Skip to content

Problem with upgrading files_encryption from OC 7 => OC 8 #14012

Closed

Description

@tomcur

Steps to reproduce

  1. Have a working installation of owncloud version 7.0.4.2 with files_encryption enabled.
  2. Attempt to upgrade to owncloud 8.0.0.7.

Expected behaviour

The upgrade should succeed.

Actual behaviour

The upgrade hangs. After disabling maintenance mode and trying again, it still hangs.

After disabling files_encryption through the occ console, the upgrade succeeded. However, encrypted files are not decrypted (and owncloud does not prompt users to decrypt their files). After re-enabling files_encryption, owncloud shows the upgrade-screen again. Upgrading still fails.

Server configuration

Operating system: Ubuntu 12.04

Web server: Apache 2.4.9

Database: MySQL

PHP version: 5.5.12

ownCloud version: 7.0.4.2=>8.0.0.7

Updated from an older ownCloud or fresh install: During upgrading

List of activated apps:

  • files
  • files_encryption
  • files_external
  • files_pdfviewer
  • files_sharing
  • files_texteditor
  • files_trashbin
  • files_versions
  • files_videoviewer
  • firstrunwizard
  • gallery
  • templateeditor
  • updater

The content of config/config.php:

<?php
$CONFIG = array (
  'instanceid' => 'oc2197ab4a5f',
  'trusted_domains' =>
  array (
    0 => 'kepow.org',
  ),
  'datadirectory' => '/www/kepow/owncloud_data',
  'dbtype' => 'mysql',
  'version' => '8.0.0.7',
  'dbname' => 'owncloud',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_Thomas',
  'installed' => true,
  'forcessl' => true,
  'mail_smtpmode' => 'php',
  'mail_smtpname' => 'thomas',
  'maintenance' => true,
  'theme' => '',
);

Are you using external storage, if yes which one: No.

Are you using encryption: Yes.

Client configuration

Browser: Issue occurs on firefox and chrome

Operating system: Windows

Logs

Web server error log

No errors are logged during the upgrade process.

ownCloud log (data/owncloud.log)

First try:

{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#282","level":3,"time":"2015-02-09T20:51:06+00:00"}
{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#283","level":3,"time":"2015-02-09T20:51:06+00:00"}
{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#284","level":3,"time":"2015-02-09T20:51:06+00:00"}
{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#287","level":3,"time":"2015-02-09T20:51:06+00:00"}
{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#288","level":3,"time":"2015-02-09T20:51:06+00:00"}
{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#289","level":3,"time":"2015-02-09T20:51:06+00:00"}
{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"PHP","message":"opendir(\/www\/kepow\/owncloud_data\/files_encryption\/keyfiles): failed to open dir: No such file or directory at \/www\/kepow\/owncloud\/lib\/private\/files\/storage\/local.php#78","level":3,"time":"2015-02-09T20:51:06+00:00"}
{"reqId":"230bd67050902ddeb36c9af31787d650","remoteAddr":"84.85.215.83","app":"core","message":"unable to rename, file does not exists : files_encryption\/Jordi.private.key","level":3,"time":"2015-02-09T20:53:38+00:00"}

Retry:

{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#282","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#283","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#284","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#287","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#288","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"Cannot modify header information - headers already sent at \/www\/kepow\/owncloud\/lib\/private\/user\/session.php#289","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"copy(\/www\/kepow\/owncloud_data\/owncloud_private_key): failed to open stream: No such file or directory at \/www\/kepow\/owncloud\/lib\/private\/files\/storage\/local.php#211","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"copy(\/www\/kepow\/owncloud_data\/public-keys): failed to open stream: No such file or directory at \/www\/kepow\/owncloud\/lib\/private\/files\/storage\/local.php#211","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"opendir(\/www\/kepow\/owncloud_data\/public-keys): failed to open dir: No such file or directory at \/www\/kepow\/owncloud\/lib\/private\/files\/storage\/local.php#78","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"opendir(\/www\/kepow\/owncloud_data\/files_encryption\/keyfiles): failed to open dir: No such file or directory at \/www\/kepow\/owncloud\/lib\/private\/files\/storage\/local.php#78","level":3,"time":"2015-02-09T20:55:39+00:00"}
{"reqId":"1637703e855ad9def0d8b34063f10a6e","remoteAddr":"84.85.215.83","app":"PHP","message":"opendir(\/www\/kepow\/owncloud_data\/owncloud_private_key): failed to open dir: No such file or directory at \/www\/kepow\/owncloud\/lib\/private\/files\/storage\/local.php#78","level":3,"time":"2015-02-09T20:55:39+00:00"}

Browser log

Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery.min.js:1
Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery-migrate.min.js:3
Content Security Policy: The page's settings blocked the loading of a resource at self ("script-src https://kepow.org 'unsafe-eval'"). index.php
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. jquery.min.js:5

Activity

  1. MorrisJobke commented on Feb 9, 2015

    @MorrisJobke
    Contributor

    cc @schiesbn

  2. added this to the milestone on Feb 9, 2015
  3. doits commented on Feb 9, 2015

    @doits

    I had the same "problem" with the hang but eventually the upgrade did not hang but instead was simply taking a really long time (> 30 minutes). strace showed the update process was opening each encrypted file (that's why I know it was doing something and therefore I did not abort it) and it was doing it at about 5 files per second ... so if you have a lot of number of files it can take some time. Maybe that's the cause here?

    Edit: The file the upgrade opened were all located in the subfolder data/username/files_encryption/ and ended with .key or fileKey or .shareKey - so I assume it encryption had to be updated.

  4. tomcur commented on Feb 9, 2015

    @tomcur
    Author

    It's certainly a possibility. I've had the upgrader running for a while (~1 hour), and I don't have a large number of files per se. I'm currently running it again and am logging the system calls using strace. It's still going strong (and quick), but I am seeing some errors, such as:

    [pid 27995] 23:52:12.429875 lstat("/www/kepow/owncloud_data/Jordi/encryption_migration_backup_2015-02-09_22-50-58/share-keys/***/***/***/***.Jordi.shareKey", 0x7fff33790390) = -1 ENOENT (No such file or directory)
    

    I also noticed that a problem with the private key associated with the user Jordi was reported in the errors logged in owncloud.log for the first upgrade attempt.

  5. schiessle commented on Feb 9, 2015

    @schiessle
    Contributor

    The upgrade will rename all encryption keys. If you have a lot of files this can take some time. We needed to re-structure the way the keys are stored to avoid file name collisions for some rare username-filename combinations. Before the upgrade script starts to rename the encryption keys it creates a backup of all your keys. So nothing should be lost. If you know how the key where stored in OC7 you can restore the backup and try to run the migration again with the occ script.

    If you are not sure how to restore the backup I can give you more details tomorrow.

  6. tomcur commented on Feb 9, 2015

    @tomcur
    Author

    I am not entirely sure how to restore the backup. Because of several upgrade attempts I now have a number of folders with names such as encryption_migration_backup_2015-02-09_16-07-16. I believe the folders from the first attempt contain everything I need.

    Should I just copy the contents of all these folders from the first attempt back to their parent directories (i.e., cp -a ./ ../) and then remove the backup folders?

  7. kkretsch commented on Feb 10, 2015

    @kkretsch

    Having a similar problem I switched back to 704. I have nearly 10GB of encrypted media which seems to upgrade for such a long time OC9 might even be released befaore it finishes.

    Any hints how to upgrade in a reasonable timeframe?

  8. schiessle commented on Feb 10, 2015

    @schiessle
    Contributor

    @Beskhue yes, take the backup from the first attempt because this should contain the state from OC7. Every user should have such a backup folder. Just that we don't lose any state I would make a manual backup from each users files_encryption folder in the current state, then delete the content of the files_encryption folder. Now copy the content of encryption_migration_backup_<date> from the first attempt for each users to files_encryption folder.

    Also in data/ you should have a system wide 'files_encryption' folder for which also backups with the pattern encryption_migration_backup_<date> should exists. Like for the users first backup the existing files_encryption folder and then copy the backup to the system wide files_encryption folder.

    Afterwards try to run the migration again ./occ encryption:migrate-keys. I would also suggest to stop your web server before you perform this steps, just to make sure that no update gets triggered somewhere in between or that any sync client tries to read some files etc.

  9. schiessle commented on Feb 10, 2015

    @schiessle
    Contributor

    @kkretsch we need to rename all encryption keys, there is no way arround it. Depending on how many files you have and how often they are shared you have more or less keys we need to migrate. But the keys are quite small files, we don't touch the actual files. So the crucial factor is the number if files and how often they are shared, not the size of the files. Renaming the keys should be possible in a reasonable time, depending on you hard disc performance. I would suggest to shutdown your web server and trigger the update with the occ command line tool to avoid any timeouts.

  10. inotriel commented on Feb 10, 2015

    @inotriel

    Maybe this is the "problem" I mentioned here #13992 (comment)

    I have about 7 oder 8 thousand files in my oc and the harddisk might not be the fastest in the world. So waiting for about 30 minutes maybe was just to little time.

    Is there any chance to see if occ is still working or stuck?

  11. schiessle commented on Feb 10, 2015

    @schiessle
    Contributor

    You could monitor the files_encryption folder of your users the size of some of the folders should change from time to time if it still runs. Also the backup folders should appear over time for the users.

  12. inotriel commented on Feb 10, 2015

    @inotriel

    Good idea, thank you. I'll give it another try tonight!

  13. 24 remaining items

  14. PVince81 commented on Feb 27, 2015

    @PVince81
    Contributor

    Looks like it's spending time trying to propagate/calculate the folder sizes, even for "files_encryption" ?! That should be blocked and maybe rescanned at the end.

    That might be what is causing the 255K database queries...

  15. icewind1991 commented on Feb 27, 2015

    @icewind1991
    Contributor

    #14573 Should greatly reduce the time the migration takes, does anyone here with a large amount of encrypted data have the opportunity to retest the migration with that patch

  16. PVince81 commented on Feb 27, 2015

    @PVince81
    Contributor

    I also noticed that the keys are copied but not moved from the old "keyfiles" to the new "keys" folder. Maybe moving them (if possible) that could provide an additional boost.

    I'll retest with that PR first.

  17. PVince81 commented on Feb 27, 2015

    @PVince81
    Contributor

    The PR works well, I also improved it further.

  18. modified the milestones: , on Mar 2, 2015
  19. DeepDiver1975 commented on Mar 2, 2015

    @DeepDiver1975
    Contributor

    too late for 8.0.1 -> 8.0.2

  20. rjaeckel commented on Mar 26, 2015

    @rjaeckel
    Contributor

    I also had the Issue that after the Timeout occured, the encryption-keys got currupted.

    For anyone who needs to recove the previous keys as well, here is a script generating the actions to be made to recover the pre-update state

    #!/bin/bash
    ### !!! needs to be run as webserver-user
    ### !!! EDIT this pattern to match all user directories in OC data directory
    userpattern='^(.{5}|cloud-administration-user)$'
    # recover user keys
    for username in $(ls -1tr|egrep -o $userpattern); do
      backup=$(ls -1tr $username|egrep '^encryption_migration_backup'|head -n1)
      if [ "x" != "x$backup" ]; then
        # echo "$username --> $backup"
        # create backup of broken state, just in case
        echo "mv $username/files_encryption $username/files_encryption.broken"
        # recreate the renamed folder
        echo "mkdir -p $username/files_encryption"
        # recover the pre-update state
        echo "cp -r $username/$backup/* $username/files_encryption"
      fi
    done
    
    # recover global encryption directories
    globbackup=$(ls -1tr|egrep '^encryption_migration_backup'|head -n1)
    for bu in $(ls -1 $globbackup); do
      echo "mv $bu $bu.broken"
      echo "cp -r $globbackup/$bu $bu"
    done
    
  21. DeepDiver1975 commented on Mar 30, 2015

    @DeepDiver1975
    Contributor

    the long execution time of the key migration will be fixed with 8.0.3

  22. rsling commented on May 13, 2015

    @rsling

    Well, it was not fixed, at least not for me! I tried multiple times to upgrade from 7 to 8.0.3 on a Debian system. The installation has 5 users and 100GB total, some folders with many small files. After 4 days, I interrupted the procedure. strace showed that the updater kept working on tens of thousands of encryption keys. This is completely useless!

  23. rjaeckel commented on May 26, 2015

    @rjaeckel
    Contributor

    @DeepDiver1975
    what about considering pcntl as an option? this would make it possible to use the whole computing power... there are several libraries here on github providing php threads this way.

  24. hostingnuggets commented on Sep 30, 2015

    @hostingnuggets

    This issue has not been fixed, see #19319

  25. locked as resolved and limited conversation to collaborators on Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions