
Estoy usando Ubuntu 12.04 como repositorio y me gustaría ver una barra de progreso cuando lo uso rsync
desde la línea de comandos. Probé la opciónsugerido en este artículo( -P
), pero prefiero ver una barra de progreso y no usar Grsync. Estoy usando rsync -P source dest
actualmente.
Respuesta1
rsync tiene una --info
opción que se puede usar no solo para generar el progreso actual, sino también la velocidad de transferencia y el tiempo transcurrido:
--info=FLAGS fine-grained informational verbosity
La explicación de cómo usarlo se encuentra en la -P
opción de la página de manual:
-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.)
Entonces lo siguiente:
rsync -r --info=progress2 --info=name0 "$src" "$dst"
Como resultado, se genera y actualiza continuamente lo siguiente:
18,757,542,664 100% 65.70MB/s 0:04:32 (xfr#1389, to-chk=0/1510)
Tenga en cuenta que cuando comienza la transferencia, el número total de fragmentos y, por lo tanto, el progreso actual, puede cambiar cuando se utiliza la opción recursiva a medida que se descubren más archivos para sincronizar.
Respuesta2
Puedes usar --progress
y --stats
parámetros.
$ 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
Depágina de manual/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.
Respuesta3
¿Qué tal esto?
rsync_param="-av"
rsync "$rsync_param" a/ b |\
pv -lep -s $(rsync "$rsync_param"n a/ b | awk 'NF' | wc -l)
$rsync_param
Evita la doble entrada de parámetros.
$(rsync "$rsync_param"n a/ b | awk 'NF' | wc -l)
Determina el número de pasos a completar.
a/ b
a/
es la fuenteb
es el objetivo
Respuesta4
Esto finalmente funcionó:
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)