2015-11-15 147 views
-1

我有一个服务器上有文件/files/category/specific/*从远程服务器到本地的rsync文件,也创建本地目录

在我的本地我有一个~/files目录。我想要做的是将/files/category/specific/*放到我的本地~/files/something/whatever。但something/whatever不存在,我想要rsync来创建这些本地目录。

我该如何使用rsync来做到这一点?

+0

'如果结果不是/文件/事/不管&&的rsync -uai服务器:/ files/category/specific /〜/ files/something /不管什么'rsync'都不会创建源主机上不存在的内容,并且在'specific'之后的'/'是必需的。 –

回答

0

试试这个:

rsync -a --relative [email protected]:/files/category/specific/* ~/files 

或者您可以使用ssh来创建一个目录或者事先用两个rsync的命令,这样

rsync -a --rsync-path=”mkdir -p ~/files/whatever/whatever/ && rsync” [email protected]:/files/category/specific/* $source 
+0

在最后一个参数中,我想指定类似于〜/ files/whatever/whatever(这些目录不存在)的东西,并且让它构建它们并将文件放在那里,这样我就不必事先使用mkdir -p。合理? – eveo

相关问题