Restoring many files from trashbin

Nextcloud version (eg, 20.0.5): NextcloudPi 20.0.9
Operating system and version (eg, Ubuntu 20.04): Raspbian GNU/Linux 10
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.38
PHP version (eg, 7.4): PHP 7.3.31

After accidentally deleting a very large folder on my device, the data is now gone. Unfortunately, the trashbin folder is too large to be displayed in the web interface and only shows the error message: “This directory is unavailable, please check the logs or contact the administrator”.
Therefore I can not restore the files manually. Anyway, there would be way too many. Is there the possibility to simply restore all files from the trashbin folder automatically? I checked that they are still there and I could just copy them to a new folder but I would prefer a way that recovers the file structure as well

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Delete a very large folder
  2. Check Deleted files

I do not really know a good solution. But maybe you can do this. I think you have got a backup that nothing can be destroyed. :wink:

  • copy / backup manually the files in trashbin
    /path/to/nextcloud/data/username/files_trashbin/files
    (or /path/to/nextcloud/data/username/files_trashbin including keys and versions)
    (maybe you can use another part of the server e.g. directory from user root: /root/)
  • use occ to delete the files in trashbin (!!! files in trashbin are deleted !!!)
    sudo -u www-data php occ trashbin:cleanup username
    Read first this.

Then for “restore” files to normal directory:

a) upload the files again to Nextcloud with Nextcloud

alternative

b.) copy files to /path/to/nextcloud/data/username/files/path/to/dir
(set the correct rights e.g. www-data:www-data, chown www-data:www-data -R path)
sudo -u www-data php occ files:scan --all
Read first this.

1 Like

Thanks for the advice!
In the end that is exactly what I did.
It would be great in the future to have an occ command to restore all files from trash given that the web interface seems to have a problem with handling large data.

1 Like