I am trying to rsync file from local to remote server. When i do this on console it works:
rsync -avzhe ssh /var/www/folder1/file5 [email protected]:/var/www/folder2
but when i do this on my php and run the php script, it doesn't work:
$rysncCommand = "rsync -avzhe ssh /var/www/folder1/file5 [email protected]:/var/www/folder2";
There is no error shown, so i can't really tell what is the error. Is there something wrong with my php script?
Best How To :
First, you need to check if you need to be a root or (sudo user) for running rsync.
If yes then exec() command will only work if it is run by same user on
php-cli (not on browser by Apache user). i.e. Which user you are loggined into shell for run
If it is root or any elavated permission user with sudo permission then, This
rsync command may not be available to
apache/www-data user which is working when php script run from browser.
So You try to make a normal user and login through it, Then try
rsync if you are successful then it may be interesting to see what are other problems can be, But if you getting access/permission denied then obviously you can not run this script at-least on browser.
Besides this One more thing permission may not be directly related to
rsync command itself but with folder
/etc/test/ which is owned by root user in normal scenario.
For more details you can check this Stack Overflow Link .