
私は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
-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
a/
源は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)