Restore and decrypt single file from backup of my nextcloud server (file encryption enabled)

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 14.0.4
Default encryption module version: 2.2.0

The issue you are facing:
I’m missing a file that was uploaded to my nextcloud (possibly deleted). All files are encrypted by the “Default encryption module”. I have a complete server and MySQL backup and could restore the missing file. Is there a way to decrypt a single restored file without restoring the complete server?

1 Like

@psar did you manage to decrypt the files from your backup? I have a similar issue, Nextcloud sync has overwritten some folders when I turned on a old desktop. Fortunately, I have the backup of all files and keys but not sure how to decrypt the files.

I’m sorry but I did not find a simple solution to restore a single file in 2019. I think it should be possible somehow but I did not spent much time to try it. In the meantime there is maybe a simple way to decrypt single files. Good luck.

Yes you can with GitHub - syseleven/nextcloud-tools: This project contains tools to operate Nextcloud.

1 Like

Do you know by chance, is Nextcloud planning to provide more tools a bit more easy to use ?
Because the occ encryption:decrypt-all [username] is nice. But as soon as we are talking about decryption from backup data, we have to use such script (the github repos you shared) and I am personnally totally lost on how to use it.

It would be really great to have an occ encryption:decrypt-all like command to do the same thing on backup data.
Just by specifying the path to the data backup directory… that would make things soooo simpler for file restoration.

And talking about file restoration: isn’t strange that occ encryption:decrypt-all does not offer a “file” option to decrypt 1 single file ? That would also be a very useful improvement.
Hopefully a developper will see this and implement the change :slight_smile:.

Maybe I should create a topic here about that. Or is there a repository centralizing issues for nextcloud infra stuff?

This would not help you either, because the occ command can only decrypt files that Nextcloud is aware of, which does not apply to files that reside in a backup archive outside of the Nextcloud data folder. Btw, Nextcloud doesn’t offer an option to restore a single unencrypted file either, because it doesn’t offer any backup and restore functionality at all out of the box.

There is a Backup app, but it doesn’t seem to be very actively developed, and honestly, I wouldn’t trust it with my important data. I also don’t know if it works with Nextcloud’s server-side encryption and if there is a way to restore individual files from backups directly through the UI, which I suspect there is not, meaning you would be in exactley the same situation as you are now as far as restoring individual files goes.

Would be great if it could.

Maybe I am wrong, because I haven’t tested it, but I think the backup nextcloud app is really user related.

Then maybe I should make a request somewhere to ask for such tools and option to be developped and made available to nextcloud admins when managing user’s data.

Maybe it’s worth to have a look at this: https://github.com/nextcloud/encryption-recovery-tools

However, If encryption of your data at rest is important, I would, whenever possible, recommend using full disk encryption via LUKS, which will be unlocked at bootime and therefore is completely transparent to the applications on your server. This will save you the headache of dealing with encryption keys and “obscure” scripts, in case you need to restore individual files from a backup.

Sure, why not: GitHub - nextcloud/server: ☁️ Nextcloud server, a safe home for all your data

2 Likes

Yes, I already through this repos, I don’t understand so well so I prefer not to use it right now.

LUKS is definitely a good idea. I will really consider it on my next machine :wink: !

1 Like

@SNS What exactly is difficult to understand when looking at the nextcloud-recovery-tools? This sounds like room for improving the documentation.

I think I had difficulties at finding where are located the values for the configuration part.
Like for example: where should I look for the configuration file of my Nextcloud instance? Where is it stored?

Or for example where can I see if " RECOVERY_PASSWORD" (the recovery feature) is activated in my configuration?

I know these are probably stupid questions, but I am not an expert in php and have difficulties locating the different files used for configuring Nextcloud.
I this that was all. Except this, the documentation is pretty clear. Just not clear enough for the noob I am.

I have the same problem, I use the server side encryption.
I i use the tool recover.php it says:
DEBUG: skipping this file because the filename structure is unknown…

Otherwise, do you think it’s possibie to restore the raw encrtyped data and the keys to decrypt it? It’s stored here files_encryption/keys or in the database?

My goal is to restore the file for the user, I don’t need to access them with decryption, only for the owner of the files.

Thanks.

@SNS Providing the RECOVERY_PASSWORD is optional. The configuration of your Nextcloud is typically located in the web folder under config/config.php.