Restoring encrypted files

I had to reinstall Nextcloud 29 on my RaspberryPi due to a Hardware-Crash on my USB-Stick… After reinstalling, I recognized that some files could not be opened due to encryption issues on my HDD. This is also valid for the signature pictures of Nextcloud, as you are able to see on the Header copy -below. How can I restore the files, which I am not able to open currently.

HBEGIN:oc_encryption_module:OC_DEFAULT_MODULE:cipher:AES-256-CTR:signed:true:useLegacyFileKey:false:encoding:binary:HEND--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\~¶bªEºS(Õò‰ÁñE	Q¶ƒmÛa¢eN‹å,b#F4ãlø©îj÷Ï»Þ¿í¦€M±ú³¹\`õbñd\~8}tᐎ—ç°ž¿âᓪd'¬<Ç&ÝLî°ï%×È„±/Dlê	\~ôÌÇçÆÃ%é¯ûCþ#Ñò³C8¾fÅ@Æ
Ëìé<¨}F6“ˆ×XÚPwKüXŸ¯"X¼ÖIÀ˜-È’‡ë¨±“Ä>3õÈä}µTGIfÚó¦ªF‘·¼òçæhßÅe—p<U—‘£¢‡Ž¹ýäH²¯AuÁŸ0iæÕyUœYÅÍ=qÖ"jøŽ6¸•õ9¤½AÜH5QåõµñóÜ{ê-ˆo½+I|÷Ü퀑\[ì8¸."˜7î£ÝÅEPŠ",{%ï¸$˜)ø´,$ón?=ªêz6¡Lo®éù´ãáûaÝ"´éJþÑ°†Sz È.ce�H5jjÎ+þ
ÌÕ·:"4t„|¦ø³ƒaáÉ}
'š›få\[ì°Ëz\_}RC$ié1lzá.æêxm‘¨&¯00iv00ÑJznö·½ðaèTÎúW:V00sig0006a9359367703b6edaf610ebcdd9ce1850390f5cf5d429766be3b991d4c7af92xxx

A standard restore should have been sufficient.

Did you restore your instance or build a complete new one?

Did you perhaps only restore your files, but not your config and database?

Restore: Restoring backup — Nextcloud latest Administration Manual latest documentation

I restored it from a Backup, which was Nextcloud 28 and updated it afterwards to Nextcloud 29.

By “it” do you mean just the contents of data/ or did you also restore your config.php and database? The former is particularly important if using encryption.

Sorry, I meant I restored it from an Image-File which I made 4 weeks before, and renewed then the Database with an occ command: ```
sudo -u www-data php occ files:scan --all

as long you still have access to your backup restore is possible using GitHub - nextcloud/encryption-recovery-tools: This project contains tools to recover files that have been encrypted with the Nextcloud End-to-End Encryption or Nextcloud Server-Side Encryption.

I am going to try this - Thank you! probiere ich mal aus - Danke → muss ich beide Skripte laufen lassen (end to end, server side)?

I do not understand the concept of recover.php, since this isn’t an executable file and it is not possible to call it via. the browser within the directory./server-side-encryption.

To be honest, it can’t be true that you lose the files you wanted to back up because Nextcloud can’t get to grips with the encryption - decryption - encryption issue… I lose my data because after a hardware crash at administration level Nextcloud is no longer able to read the data on the HDD via an image file backed up installation…

nobody can tell you why it doesn’t work - likely your backup strategy failed. so far an important learning - each backup is only as good as your restore process - this must be evaluated regularly and not only in case of disaster. in general you might not fully understand the goal of server encryption - please familiarize yourself with the tools your are using.

regarding the tools - they come with a comprehensive guide and many people successfully recovered files in the past. RTFM please!

1 Like

What, precisely, did your “image” backup contain?

In Nextcloud there are multiple bits of “data” that are all important to back up:

  • Contents of your configured datadirectory (what most people think of as their “data”)
  • Contents of your config/ folder
  • Contents of your chosen database

If you had to run occ files:scan after your restore I’m concerned you didn’t have all the elements covered.

Sorry if I exaggerated my previous answer. I am going to try it further with recover.php. The Image File contained a copy of the Nano-SD-Card with the Nextcloud Installation and all adjustments to access the HDD.

…so far so good: I have provided my secret, my user password and my instance-id → NC_Admin is the target directory, Nextcloud-Admin is the source. here are the results:
ubuntu@ubuntu:~/encryption-recovery-tools/server-side-encryption$ php recover.php /media/disk/data/NC_Admin /media/disk/data/Nextcloud-Admin|*

PHP Warning: scandir(/media/disk/data): Failed to open directory: Permission denied in /home/ubuntu/encryption-recovery-tools/server-side-encryption/recover.php on line 1226

PHP Warning: scandir(): (errno 13): Permission denied in /home/ubuntu/encryption-recovery-tools/server-side-encryption/recover.php on line 1226

PHP Warning: foreach() argument must be of type array|object, bool given in /home/ubuntu/encryption-recovery-tools/server-side-encryption/recover.php on line 1227

do i have to enable server-side-encryption before running recover.php?

No.

But based on the error you do have a permission problem at the OS level.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.