0

On Ubuntu 18.04 I am running a small PHP web application which moves directories one by one with nested dirs and files from one filesystem to another via exec(mv filepath) method.

Now I have the problem that when a nested directory or file is missing read rights or is somehow corrputed the mv fails (because it cannot delete the file in the src). But at that point the data is already moved into dest.

Which means in the end I have a fully copied dir in dest and still the dir in src but only with the dirs/files which have invalid permission or are corrupted. I do not want this behaviour. As soon as the mv fails for whatever reason it should revert the whole process/leave src as it was.

In my PHP Script I already check if the mv fails. If yes I could then check if the dir exists in dest and mv back to src.

But is there no better/easier way to achieve this bahaviour?

3

0

You must log in to answer this question.

Browse other questions tagged .