rsync 排除指定目录

背景

将Server1上的数据同步到Server2;

Server1目录结构:

/us_data/yahoo
             └── qlib
                    ├── calendars
                    ├── dataset_cache
                    ├── features
                    ├── features_cache
                    └── instruments                    

Server2目录结构:

data
   └── us_qlib_data
                  └── yahoo
               
└── qlib

我需要将 Server1 里的 qlib 传到 Server2 yahoo 目录下;

并且 Server1Server2 传时排除 dataset_cachefeatures_cache 这两个目录;

rsync代码

主要使用了 rsync 的 --exclude 参数

rsync -Lrza /data2/pezhu/us_data/yahoo/qlib/ --exclude dataset_cache/ --exclude features_cache/  Server2用户名@Server2的IP:/data/us_qlib_data/yahoo/qlib

# 执行后,会提示输入Server2 的密码,输入即可

我直接用python 中 os.system() 执行了代码:

rsync -Lrza /data2/pezhu/us_data/yahoo/qlib/ --exclude dataset_cache/ --exclude features_cache/  Server2用户名@Server2的IP:/data/us_qlib_data/yahoo/qlib

猜你喜欢

转载自www.cnblogs.com/bigtreei/p/11763865.html