Hi Guillaume,
We have been experiencing problems that may be connected to what you are experiencing - we haven't implemented a fix but you might find the tracker issues listed below of interest.
In our case our restore/import processes are failing when there are more than about 10-12 files in a folder (this is also applicable to the legacy files folder).
Here are a few tracker issues that might help (although there hasn't been any progress in recent months):
https://tracker.moodle.org/browse/MDL-40168
https://tracker.moodle.org/browse/MDL-41007
https://tracker.moodle.org/browse/MDL-34744
John