To be truthful, I don't really know if this is caused by symlinks or rsync but I've stopped using symlinks and migrated over to using rsync months ago. So I guess this is just to be sure %100.

This is my command: rsync -azsL $src $dst and how I use it as a function in php;

protected function cloneDirectory($src, $dst) {
    if (!is_dir($dst)) {
      mkdir($dst, 0777, true);

    $command = "rsync -azsL $src $dst";
    exec($command, $output, $return_val);

I'm not sure if the source string has a trailing slash or not but if the solution is to add a trailing slash, can be done easily.

Structure of source directory:

{content_id}/system: consists of files and directories and I bundle one or more of these into the destination. Example;

x (folder_x/system/...)
y (folder_y/system/...)

So the goal is to merge the contents of both x/system and y/system in destination and I end up having an infinite system/system/ for ever.

Is this potentially caused by rsync? If so, how can I stop this from happening?

enter image description here

1 Answer 1


Follow the example below.

If I have src=/a/b/test path having the file test and another is dst=/c/d. If I need to rsync that file from src to destination.

I will use this command.

rsync -azsL /a/b/ /c/d

So, the solution for your problem is:

src=x/system/ dst=y/system

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .