0

我的 rsync bash 脚本没有解析通过 php 生成的 --exclude-from 文件,但如果我在本地手动创建(以 root 身份)完全相同的文件,它将解析。我在 Xubuntu 12.10 系统上有一个 Web 界面,它在本地写入 rsync --exclude-from 文件,然后通过 rcp 将它们推送到运行 rsync 脚本的(CentOS 6)备份盒。(请不要对 rcp 摇摆不定……我知道——在这种情况下别无选择。)

网页写入文件:

PHP:

file_put_contents($exclfile, $write_ex_val);

然后从网络服务器上的本地 bash 脚本推送到备份盒:

重击:

rcp -p /path/to/file/${servername}_${backupsource}.excl ${server}:/destination/path

我已经将手动创建的文件(有效)的权限和所有权与 php/rcp'd(无效)相同的文件进行了比较,它们都是相同的:

重击:

stat -c '%a' server_backupsource_byhand.excl 
644

stat -c '%a' server_backupsource_byphp.excl 
644

ls -l server_backupsource_byhand.excl 
-rw-r--r-- 1 root root 6 May 11 05:57 server_backupsource_byhand.excl 

ls -l server_backupsource_byphp.excl 
-rw-r--r-- 1 root root 6 May 11 05:58 server_backupsource_byphp.excl 

如果它是相关的,这是我的 rsync 行:

重击:

rsync -vpaz -v --exclude-from=${exclfile} /mnt/${smbdir} /backup

我怀疑 php 可能正在以不同的格式(例如 UTF8 而不是 ANSI)编写文件,但我无法弄清楚如何对此进行测试,并且这里的知识有限。

有人对如何获取 php/rcp 生成的文件进行解析有任何建议吗?

4

1 回答 1

0

Using diff and file I found out that the php-written version wasn't writing the newline. In my variable definition I was using a "." as "$write_ex_val ." Removing this "." let php write the new lines. I also removed the space between the variable and "\n", although I'm not sure if this contributed to the solution. I'd upvote the comment, Earl, but I don't think I have enough rep. Thanks again.

于 2013-05-11T13:55:24.813 回答