机器生产:
FS - /u01/oracle/prod/product/11.2.0.3
机器测试:
FS -/u01/oracle/test/product/11.2.0.3
我想排除/u01/oracle/test/product/11.2.0.3/dbs, /u01/oracle/test/product/11.2.0.3/network
我不确定以下命令是否可以在test machince中运行
[test@oracle] rsync -av --delete --exclude 'dbs','network' production:/u01/oracle/prod/product/11.2.0.3/ /u01/oracle/test/product/11.2.0.3
请告诉我如何继续。
答案 0 :(得分:0)
试试这个
rsync -av --exclude /u01/oracle/test/product/11.2.0.3/dbs --exclude /u01/oracle/prod/product/11.2.0.3/network source/destination/ /u01/oracle/prod/product/11.2.0.3/ /u01/oracle/test/product/11.2.0.3/
<强>解释强>
rsync -av --exclude folder1 --exclude folder2 --exclude file1.txt source destination
关注:对于OP的问题,添加工作代码段
prod@openvas:~/testrsync$ ls -laRt
drwxr-xr-x 4 prod prod 4096 Nov 12 10:48 source
drwxr-xr-x 3 prod prod 4096 Nov 12 10:47 destination
./source:
drwxr-xr-x 2 prod prod 4096 Nov 12 10:48 deletethis
drwxr-xr-x 2 prod prod 4096 Nov 12 10:47 dontdelete
./source/deletethis:
./source/dontdelete:
-rw-r--r-- 1 prod prod 0 Nov 12 10:47 a.txt
./destination:
drwxr-xr-x 2 prod prod 4096 Nov 12 10:47 dummyfolder
./destination/dummyfolder:
以上是此案例的数据集。 source有2个文件夹作为deletethis和dontdelete(文件a.txt)。目的地有一个虚拟文件夹。
所以我正在执行以下命令
prod@openvas:~/testrsync$ rsync -av --delete --exclude /home/prod/testrsync/source/dontdelete/ /home/prod/testrsync/source/
/home/prod/testrsync/destination/
sending incremental file list
./
deleting dummyfolder/
deletethis/
dontdelete/
dontdelete/a.txt
sent 166 bytes received 42 bytes 416.00 bytes/sec
total size is 0 speedup is 0.00
结果如下
prod@openvas:~/testrsync$ ls -laRt
drwxr-xr-x 4 prod prod 4096 Nov 12 10:48 source
drwxr-xr-x 4 prod prod 4096 Nov 12 10:48 destination
./source:
drwxr-xr-x 2 prod prod 4096 Nov 12 10:48 deletethis
drwxr-xr-x 2 prod prod 4096 Nov 12 10:47 dontdelete
./source/deletethis:
./source/dontdelete:
-rw-r--r-- 1 prod prod 0 Nov 12 10:47 a.txt
./destination:
drwxr-xr-x 2 prod prod 4096 Nov 12 10:48 deletethis
drwxr-xr-x 2 prod prod 4096 Nov 12 10:47 dontdelete
./destination/deletethis:
./destination/dontdelete:
-rw-r--r-- 1 prod prod 0 Nov 12 10:47 a.txt