Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux rsync将文件更改为其他目录_Linux_Rsync - Fatal编程技术网

Linux rsync将文件更改为其他目录

Linux rsync将文件更改为其他目录,linux,rsync,Linux,Rsync,我试图从远程到本地对rsync执行的操作,并将所有更改的文件放在不同的目录中 例如,在远程框中 /tmp -file1.txt -file2.txt -file3.txt 在我的本地 /tmp -file1.txt -file2.txt /new 如果我做rsync,我的本地 /tmp -file1.txt -file2.txt -file3.txt /new -file3.txt 如何执行此操作?请尝试选项--compare dest=DIR,例如: rsync -

我试图从远程到本地对rsync执行的操作,并将所有更改的文件放在不同的目录中

例如,在远程框中

/tmp
 -file1.txt
 -file2.txt
 -file3.txt
在我的本地

/tmp
 -file1.txt
 -file2.txt

/new
如果我做rsync,我的本地

/tmp
 -file1.txt
 -file2.txt
 -file3.txt

/new
 -file3.txt
如何执行此操作?

请尝试选项
--compare dest=DIR
,例如:

rsync --compare-dest=/tmp remotebox:/tmp /new

我不得不做一些修补,让它为我正常工作,但基本上我必须使用rsync两次。这对我来说似乎大错特错,但只要它对我有效,那就没关系了。第一次调用使用
--compare dest
仅将新文件同步到
/new
文件夹。第二次调用将
/tmp
文件夹同步为正常

它应该是这样的:

rsync --compare-dest=/tmp remotebox:/tmp /new
rsync remotebox:/tmp /tmp

如果你能得到这个问题的答案,那会很有趣,但我认为rsync没有这个功能。如果我必须解决这个问题,我会将rsync调用嵌入到一个脚本中,该脚本在/tmp之前和之后进行了比较,并记录了任何新的或更改的文件!