简体   繁体   English

Rsync-将源拆分为多个集合

[英]Rsync - split source as multiple sets

I had the source directory : 我有源目录:

root/sourceDir1/sourceDir11
root/sourceDir1/sourceDir12
root/sourceDir1/sourceDir13
root/sourceDir1/sourceDir14
root/sourceDir2/SourceDir21
root/sourceDir2/SourceDir22
root/sourceDir2/SourceDir23
root/sourceDir2/SourceDir24
root/sourceDir2/SourceDir25
root/sourceDir2/SourceDir26

How can I use rsync command to sync these directories as specified in below: 如何使用rsync命令同步这些目录,如下所示:

rootTarget1/sourceDir11
rootTarget1/sourceDir12
rootTarget1/sourceDir13
rootTarget1/sourceDir14

rootTarget2/sourceDir21
rootTarget2/sourceDir22
rootTarget2/sourceDir23
rootTarget2/sourceDir24
rootTarget2/sourceDir25
rootTarget2/sourceDir26

Basically I would like to split the source directories into 2 sets, one set of dirs should sync to rootTarget1 and another set should sync to rootTarget2 基本上,我想将源目录分为两组,一组目录应同步到rootTarget1,另一组目录应同步到rootTarget2

try this script: 试试这个脚本:

#!/bin/bash
for ((x=1;x<=2;x++));
do if [ x = 1 ] ;
    then for ((y=1;y<=4;y++)); 
             do rsync root/sourceDir${x}/SourceDir${x}${y} rootTarget${x}/Sourcedir${x}${y}" ;
         done ;
   else for ((y=1;y<=6;y++)) ; 
             do rsync root/sourceDir${x}/SourceDir${x}${y} rootTarget${x}/SourceDir${x}${y}" ;
         done ;
   fi;
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM