Ubuntu 12.04 をレポとして使用していますが、コマンドラインから rsync
を使用する際にプログレスバーを表示させたいと考えています。 この記事で提案されている](http://www.cyberciti.biz/faq/show-progress-during-file-transfer/) (-P
) というオプションを試しましたが、私はプログレスバーを表示してGrsyncを使用しない方が好きです。現在、rsync -P source dest
を使用しています。
rsync には --info
オプションがあり、現在の進行状況を出力するだけでなく、転送速度や経過時間を出力することができます。
--info=FLAGS fine-grained informational verbosity
使い方の説明は、manページの -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)
転送開始時にチャンクの総数、つまり現在の進行状況は、recursive オプションが使用されている場合、同期するファイルがより多く検出されると変化する可能性があることに注意してください。
これはどうでしょう?
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
はターゲットこれでようやく成功した。
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)