简体   繁体   English

在PHP中使用rsync将远程服务器文件夹与本地服务器文件夹同步?

[英]sync a remote server folder with local server folder using rsync in php?

This code in php it doesn't sync the "test" folders. 此代码在php中不会同步“测试”文件夹。

php 的PHP

exec('/usr/bin/rsync -a /etc/test root@x.x.x.x:/etc/test');

But in shell 但在

rsync -a /etc/test/ root@x.x.x.x:/etc/test/

is worked. 工作。 So I need to sync those "test " folders by using php file.How could I do that? 所以我需要使用php文件同步那些“测试”文件夹。我该怎么办?

First you need to check if you need to be a root or (sudo user) for running rsync. 首先,您需要检查是否需要以root用户或(sudo用户)身份运行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). 如果是,则exec命令仅在由同一用户在php-cli上运行时才起作用(而不是由apache用户在浏览器上运行)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 直接从 URL 下载文件到本地文件夹或远程服务器中的文件夹 - Download file directly from URL to local folder or a folder in remote server 使用PHP将zip文件夹上传到远程服务器上? - upload zip folder onto remote server using PHP? 如何使用PHP代码获取远程服务器文件夹的路径? - How to get the path of a remote server folder using PHP code? 无法使用PHP在远程服务器中递归创建文件夹 - Unable to create folder recursively in remote server using PHP 用php压缩远程ftp服务器上的整个文件夹 - compress a whole folder on remote ftp server with php 纯PHP中远程服务器的镜像文件夹 - Mirror folder from remote server in pure PHP 如何使用php将文件夹从Web服务器下载到本地计算机 - How to download a folder from web server to local machine using php 如何使用PHP将一个文件夹本地文件复制到SFTP服务器 - How to Copy one folder local file to SFTP server using PHP 如何使用远程服务器上的 php 删除本地工作副本上的 hidden.svn 文件夹? Unlink() 权限被拒绝 - How can I delete the hidden .svn folder on my local working copy using php on a remote server? Unlink() permission denied 使用php脚本中的rsync同步本地和远程文件夹,而无需输入密码 - Sync local and remote folders using rsync from php script without typing password
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM