Decryption Issues

Hi guys,

I’m trying to decrypt all files for user (ABC) on a hoster based NV 9.0.51 system (All-INKL) w/ PHP 7.01
Unfortunately the decryption process never comes to a defined end but gets interrupted by PHP errors

like:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 81 bytes) in /www/htdocs
/w005850c/wwwcloud/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php on line 128

or:
Doctrine\DBAL\Exception\DriverException]
An exception occurred while executing ‘UPDATE ZIuXd_appconfig SET configvalue = ? WHERE (appid = ?) AND (configkey =
?) AND (configvalue <> ?)’ with params [“yes”, “core”, “encryption_enabled”, “yes”]:
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

[PDOException]
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

It seems, when observing the /data directory for the specified user (ABC), that most, if not all files have successfully been decrypted already… but after a couple of tries I have also a couple of decrypted files for each encrypted one in that directory (see below)

occ command chain:
php occ maintenance:singleuser --on
php occ encryption:enable
php occ encryption:decrypt-all ABC


decrypt files for user ABC (1 of 1): /o815/files/XX__IMG3537.jpg
decrypt files for user ABC (1 of 1): /o815/files/XX/__IMG3537.jpg.decrypted.1475774188
decrypt files for user ABC (1 of 1): /o815/files/XX/__IMG3537.jpg.decrypted.1475775536
ecrypt files for user ABC (1 of 1): /o815/files/XX/__IMG3537.jpg.decrypted.1475781045

How shall I deal with this ??

  • The effect of course is also that I’m reaching my storage maximum this way… I actually quadrupelled the amout of used storage by three tries of decryption so far…

Can I delete manually through FTPing and DELETING into the /data directory ??

  • if YES, Which files should I delete manually ?? the encrypted or all decrypted versions ??
  • if NO, same question for the WebGUI …which files to delete

I assume that, if the decryption would have finished “normally” without errors, the script would have automatically replaced the formerly encrypted files with the decrypted files… and deleted all -in between files- CORRECT ??

Any other hints ??

Besides:

  • when FTP downloading some files (jpgs) directly from the /data directory, I can confirm that all “marked decrypted” files have been correctly decrypted and can be opened without issue

  • when viewing the files through the WebGui, all file versions, original encrypted and all decrypted ones are visible, but only the original encrypted can be opened and viewed (jpg)

Thank’s for any support and/or hints in this matter…

Oliver

This means you hit the memory limit configured for PHP. Try increasing the amount of memory PHP can use from 128MB to 256MB or higher depending on need.

This means your SQL server has stopped working or the connection has been inturrupted. This can be anything from a limit on the query run length, to a limit on the connection time. It is also possible you hit the max execution time of your PHP script.

In any of the cases, you need to configure higher resource limits. Your hosting provider would be best able to help you with that.

Thank’s … that’s what I guessed already… will contact them

BUT,
any Idea how to deal with the files created already ??? which ones and how to delete ??

Please update to the latest version 9.0.54 where the database problem should be solved (NC reconnects automatically): https://nextcloud.com/changelog/

In a first step, I wouldn’t delete any files. However, I would perhaps backup the already decrypted files.

  • Upgrade done to 9.0.54

tried also:

  • php_value memory_limit 512M
  • php_value memory_limit 1024M
    in .htaccess in NextCloudRootDirectory

all without success…

Diiferent ERROR on different decryption runs:
[------>---------------------]
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /www/htdocs/w000000c/www/xcloud/lib/private/files/cache/cache.php on line 201

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /www/htdocs/w000000c/www/xcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php on line 128

ANY OTHER INFOS/HINTS ??

Thank’s a lot in advance

ADDITIONALLY I just figured that for the specified user (above, ABC),

a file scan:
php occ files:scan ABC

results in 0 Folders / 0 Files / ElapsedTime 00:00:00 !!!

But there are for sure a lot of files owned by this user (and beeing shown in the users Folders & WebGui)
also a lot beeing successfully shared with other users…

Scans for other users show correct files/folders etc…

I’M getting more and more LOST…

The files in the error messages being different just means that PHP ran out of memory in a slightly different spot.

That means the memory limit is still set to 128M(134217728 bytes), which makes sense:
.htaccess is only used by Apache, not when running PHP from the command line.

To change it, you need to edit the php config file (which will probably be something like /etc/php/cli/php.ini)
Or you could try passing the option on the command line:
php -d memory_limit=256M occ encryption:decrypt-all ABC

Hey rigrig,

thank’s for this very helpfull hint - but I guess I’m still not there yet… !!!

Now… decrypting ran for about an hour with “some success” by your suggested command:
php -d memory_limit=512M occ encryption:decrypt-all ABC

…and finished decrypting all files with the following message:

starting to decrypt files… finished
[============================]

Files for following users couldn’t be decrypted,
maybe the user is not set up in a way that supports this operation:
ABC

As mentioned in my previous message before… I get ZERO folders and ZERO files shown when I occ files:scan ABC
Something else must be wrong as well with the user…

A post was split to a new topic: How to decrypt files