# Restoring many files from trashbin

**URL:** <https://help.nextcloud.com/t/restoring-many-files-from-trashbin/141819>\
**Category:** ℹ️ Support\
**Tags:** trashbin, files\
**Created:** [July 7, 2022, 8:25am UTC](https://help.nextcloud.com/t/restoring-many-files-from-trashbin/141819 "2022-07-07T08:25:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aghatroy](https://help.nextcloud.com/letter_avatar/aghatroy/32/5_5575768a8748004e209b776fc1b2916d.png) [@aghatroy](https://help.nextcloud.com/u/aghatroy)\
**Post date:** [July 7, 2022, 8:25am UTC](https://help.nextcloud.com/t/restoring-many-files-from-trashbin/141819/1 "2022-07-07T08:25:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [July 8, 2022, 8:54am UTC](https://help.nextcloud.com/t/restoring-many-files-from-trashbin/141819/2 "2022-07-08T08:54:30Z")

</div>

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. 😉

- 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](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#trashbin).

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](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#file-operations).

---

<div class="post-metadata">

**Author:** ![aghatroy](https://help.nextcloud.com/letter_avatar/aghatroy/32/5_5575768a8748004e209b776fc1b2916d.png) [@aghatroy](https://help.nextcloud.com/u/aghatroy)\
**Post date:** [July 12, 2022, 7:30am UTC](https://help.nextcloud.com/t/restoring-many-files-from-trashbin/141819/3 "2022-07-12T07:30:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 13, 2024, 2:27pm UTC](https://help.nextcloud.com/t/restoring-many-files-from-trashbin/141819/4 "2024-12-13T14:27:24Z")

</div>


