I wonder if this is possible. Basically, I am trying to write a very basic script to help me speed up the upgrade process of several installs of a CMS system (where I need to copy across certain folders).
So let's say I have a folder:
/home/sites/domain.co.uk/public_html/folder1/folder2/files
What I need to do is copy the folder tree and only copy the files in the files folder.
At the moment I am using rsync -a via:
<?php
exec("rsync -a /home/sites/domain.co.uk/public_html/folder1/folder2/files /home/sites/domain.co.uk/copy");
?>
The problem with this is instead of creating the following:
/home/sites/domain.co.uk/copy/folder1/folder2/files
it creates
/home/sites/domain.co.uk/copy/files
Is there a way to use rsync to copy the previous folders / structure as well so I end up with?
/home/sites/domain.co.uk/copy/folder1/folder2/files
I'm quite happy to use rsync as opposed to creating a full php script etc
functionality of rsync is to transfer files from one location to another OR from one server to another(if you have root access to other folder) In your following example
<?php
exec("rsync -a /home/sites/domain.co.uk/public_html/folder1/folder2/files /home/sites/domain.co.uk/copy");
?>
There must be files
folder on your server at given path which contains files and in copy
folder all those files will be transferred.
instead you can try below command to transfer your files
<?php
exec("rsync -auv -e ssh --progress /home/sites/domain.co.uk/public_html/folder1/folder2/files /home/sites/domain.co.uk/copy");
?>
--progress
will show which file is being transferred.