執行 rsync 時如何檢視進度條?

執行 rsync 時如何檢視進度條?

我使用 Ubuntu 12.04 作為儲存庫,並希望在從rsync命令列使用時查看進度列。我嘗試了這個選項本文建議( -P),但我喜歡看到進度條而不使用 Grsync。我目前正在使用rsync -P source dest

答案1

rsync 有一個--info選項,不僅可以用來輸出當前進度,還可以輸出傳輸速率和經過的時間:

--info=FLAGS            fine-grained informational verbosity

如何使用它的說明位於-P手冊頁的選項下:

-P     The -P option is equivalent to --partial --progress.  Its purpose is to
       make it much easier to specify these two options for a long transfer that
       may be interrupted.

       There is also a --info=progress2 option that outputs statistics based on
       the whole transfer, rather than individual files.  Use this flag
       without  out‐putting  a  filename  (e.g. avoid -v or specify --info=name0)
       if you want to see how the transfer is doing without scrolling the screen 
       with  a  lot  of names.   (You  don’t  need  to specify the --progress
       option in order to use --info=progress2.)

所以如下:

rsync -r --info=progress2 --info=name0 "$src" "$dst"

結果如下輸出並不斷更新:

18,757,542,664 100%   65.70MB/s    0:04:32 (xfr#1389, to-chk=0/1510)

請注意,當傳輸開始時,當使用遞歸選項時,區塊的總數以及當前的進度可能會發生變化,因為會發現更多檔案進行同步

答案2

您可以使用--progress--stats參數。

$ rsync -avzh --progress --stats root@server:/path/to/file output_name

root@server's password: 
receiving incremental file list
file
         98.19M  54%    8.99MB/s    0:00:08

手冊頁/explainshell:

-a, --archive
-v, --verbose
-z, --compress
-h, --human-readable

--progress  This  option  tells  rsync to print information showing
 the progress of the transfer. This gives a bored user something to
 watch.  Implies --verbose if it wasn’t already specified.

--stats  This  tells  rsync to print a verbose set of statistics on
 the file transfer, allowing you to tell how effective rsync’s
 delta-transfer algorithm is for your data.

答案3

這個怎麼樣?

rsync_param="-av"
rsync "$rsync_param" a/ b |\
     pv -lep -s $(rsync "$rsync_param"n a/ b | awk 'NF' | wc -l)
  • $rsync_param

    避免重複輸入參數

  • $(rsync "$rsync_param"n a/ b | awk 'NF' | wc -l)

    確定要完成的步驟數。

  • a/ b

    1. a/是源頭
    2. b是目標

答案4

這終於奏效了:

rsync "$rsync_param" -a --prune-empty-dirs --exclude "*.iso" rsync://archive.ubuntu.com/ubuntu/indices/ /repo/ubuntu/indices | pv -lep -s $(rsync "$rsync_param"n rsync://archive.ubuntu.com/indices/ /repo/ubuntu/indices | awk 'NF' | wc -l)

相關內容