Restore a large volume of files deleted by error

Nextcloud version (eg, 20.0.5): 25.0.1

Pb I am facing :thinking:

a user has deleted 27000 files, 40 Go !!
All the files are in its trashbin, I can see them.

  1. I have tried to restaure them via the web interface. It bugs after 2hours and only around 1000 files. Some of them are restored in the right folder, other are directly under the parent folder but not in the right sub-folder.

2 I do not want to restore all its trashbin but just between 2 dates (I have the timestamp).

Is it possible to do it directly via the database ? Is there a script to restore them more easily ?

  1. Is it possible to block the deletion of a large volume of files, or ask a confirmation ?

Help please.


Someone tried to use an API endpoint to restore files:

Now you need a list of all the deleted files (not sure if that is possible via API, probably somehow).

You can do a lot with occ

occ trashbin:restore --help
  Restore all deleted files

  trashbin:restore [options] [--] [<user_id>...]

  user_id                restore all deleted files of the given user(s)

      --output[=OUTPUT]  Output format (plain, json or json_pretty, default is plain) [default: "plain"]
      --all-users        run action on all users
  -h, --help             Display help for the given command. When no command is given display help for the list command
  -q, --quiet            Do not output any message
  -V, --version          Display this application version
      --ansi|--no-ansi   Force (or disable --no-ansi) ANSI output
  -n, --no-interaction   Do not ask any interactive question
      --no-warnings      Skip global warnings, show command output only
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

unfortunately there is no option for restoring only files deleted in a certain time-window but you could first permanently delete the files that should not be restored (sort files in trashbin by time/date of deletion and select range) and then run the occ command.

Without having done this, it looks to me as one of the simpler operations.

Much luck!

Thank you all.

Unfortunatly if I restore all the files deleted from this users, I will restore also hundreds of files not necesseray.

I have done it slowly from the web interface where the date of deletion is mentioned.

An idea for an improvment : be able to filter the page Deleted files :wink: ?

Here you can get deleted files with the date:

OK thank you, I will try