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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM