背景
將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 目錄下;
並且 Server1 往 Server2 傳時排除 dataset_cache 和 features_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