0

机器生产:

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@oracle] rsync -av --delete --exclude 'dbs','network' production:/u01/oracle/prod/product/11.2.0.3/  /u01/oracle/test/product/11.2.0.3

请让我知道我应该如何进行。

4

1 回答 1

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:

以上是本案例的数据集。其中源有 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

看一下这个

于 2013-11-11T11:54:59.080 回答