歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux遠程拷貝(限速和斷點續傳)

# scp 拷貝本地文件filename  到遠程機器 192.168.188.188 服務器的/data/tmp目錄下 
   scp -P 61204 -l 40000 filename [email protected]:/data/tmp/

 -P port   
             Specifies the port to connect to on the remote host.  Note that this option is written with a capital ‘P’, because -p is already reserved
             for preserving the times and modes of the file in rcp(1).
#-P指定遠程服務器ssh服務的端口  如:ssh端口為61204

 -l limit
             Limits the used bandwidth, specified in Kbit/s.
-l 指定拷貝的速度限制 單位是ct/s   如:-l 40000 表示40000Kbit/s=40000/8KB=5MB的速度

注:scp不支持斷點續傳

rsync + ssh 斷點續傳
#rsync同步本地文件 filename  到遠程機器 192.168.188.188 服務器的/data/tmp目錄下
rsync -avzP -e 'ssh -p 61204' --bwlimit=5000 filename [email protected]:/data/tmp/ >> scp_to_101.log 
-a:以archive模式操作,復制目錄、符號連接,等價於 -rlptgoD 。
-v:詳細提示 
-z:壓縮
-P:是綜合了--partial --progress兩個參數
    --partial
    如果在拷貝文件的過程中,傳輸被中斷,rsync的默認操作是撤消前操作,即從目標機上刪除已拷貝的部分文件。
    如果想在下次拷貝時續傳文件,不需要重新拷貝所有文件的話,可以使用-partial選項阻止rsync在傳輸中斷時刪除已拷貝的部分
    --progress 顯示進度條
-e:參數的作用是可以使用戶自由選擇欲使用的shell程序來連接遠端服務器
     ssh -p 61204 指定ssh的端口(非默認22)61204
--bwlimit: --bwlimit=5000  限制帶寬為5000k Bytes/s =5MB
上例:使用rsync傳輸本地文件filename到192.168.188.188的/data/tmp目錄下  使用壓縮歸檔傳輸、限速5MB、支持斷點續傳 使用ssh協議 

詳情 可以參考 man scp 和man rsync 手冊 

Copyright © Linux教程網 All Rights Reserved