linux 複製目錄中含有隱藏檔案和連結如何處理
阿新 • • 發佈:2019-01-04
1.
cp -Rp ——-不會複製隱藏檔案,符號連結的建立時間改變為複製時間了,硬連結被作為檔案複製了,
2
cp -a ————-可以作為比較小的複製,資料量大,可能因記憶體不足,導致失敗
3
tar cvf - * | (cd /dest/dir && tar xvfp -) ——————,隱藏檔案不會複製,符號連結時間還是複製時間
4
find . -depth | xargs tar cvf - | (cd ../tar_cp/ && tar xvfp -)
find . -depth | xargs tar cvf - | ssh machine_name ‘(cd ../tar_cp/ && tar xvfp -)’
depth可以解決目錄不能訪問許可權不能進入的問題
5
find . -depth | cpio -dampv {/dest/dir}
find . -depth | ssh machine_name ‘cpio -dampv {/dest/dir}’
目標軟連線和目錄的修改時間是命令執行時間
6
rsync -av /src/dir/ /dest/dir
/src/dir/ 最後的/不能少,否則是複製目錄dir而不是目錄下的內容
軟連線仍然是複製時間
rsync -avz -e ssh [email protected]:/src/dir/ /dest/dir
-z壓縮
-e指定遠端使用shell