Datei in GNU / Linux mit Fortschrittsbalken und Geschwindigkeitsbegrenzung kopieren

9874
Vi.

Gibt es ein gutes Werkzeug in GNU / Linux, das Dateien kopiert cp, aber auch Fortschritt anzeigt und Geschwindigkeit begrenzt (und Änderungen ohne Unterbrechung) ohne Unterbrechung pv?

Prototyp:

find source_directory | cpio -H newc -o | pv -s `du -bs source_directory/ | awk ''` | (cd /destination/directory && cpio -di) 

Auch rsync -aP source_directory /destionation/directory/, aber dies zeigt Fortschrittsbalken einzeln und kann sich nicht ändern Rate nach dem Start.

Oder vielleicht sollte ich einfach einen Wrapper für pv / cpio schreiben? Erledigt.

7

3 Antworten auf die Frage

9
Vi.

Das Skript wurde geschrieben, um mit find, cpio und pv die Aufgabe auszuführen. Die Rate kann begrenzt werden.

http://vi-server.org/vi/bin/cppv

Es hier spiegeln:

#!/bin/bash   set -e  if [ $# -lt 2 ]; then echo "cppv - copy files with progress bar and rate limiting ability" echo "Usage: cppv source_file[s] destination_file_or_directory" echo "No other non-positional command line arguments can be given" echo "Always recurses like find" echo "You can change copying speed limit on the fly with \"pv -R\" if you find out pv's PID" echo "Use FIND_OPTS, PV_OPTS, CPIO_O_OPTS, CPIO_I_OPTS to override arguments to the pipeline parts" echo "Examples:" echo " cppv a b # Copy file a to b. Just calls \"pv a > b\"" echo " cppv a d/ # Copy file a to d/a. Calls \"find a | cpio -o | pv | (cd d && cpio -i)\"" echo " cppv **.mkv /mnt/usb/ # Copy all matching files to /mnt/usb/." echo " cppv dir1 dir2 # duplicate dir1" echo " PV_OPTS=\"-L 1M\" cppv . /tmp/ # Limit copying rate to 1M" echo " cppv /home/vi/bin /tmp/ # Warning: Copy /home/vi/bin to /tmp/home/vi/bin" exit 1 fi;  true $ true $ true $  ARGS=( "$@" );  DEST="$" unset ARGS[$#-1];  if [[ ( "$" == "-" && ! -e "$1" ) || ( "$" == "-" && ! -e "$DEST" ) ]]; then echo "There should not be any command line options. Only file names." >&2 exit 1; fi  DIRMODE=0  if [[ $# > 2 || "$-1:1}" == "/" || -d $DEST ]]; then DIRMODE=1 elif [[ -d "$1" && ! -d "$2" ]]; then DIRMODE=1 mkdir "$DEST"; DEST=`readlink -f "$DEST"`; cd "$1"; ARGS=(".") fi  if [ $DIRMODE == 0 ]; then pv "$1" > "$2" && exit 0; fi;  if [ ! -d "$DEST" ]; then echo Not a directory: "$DEST" >&2 exit 1 fi  if [ "$" == "/" ]; then echo "Warning: it will do a bit different thing than usual cp" >&2 echo " For example, copying $1 to $DEST$1, not to $DEST/`basename $1`" >&2 fi  SIZE=`du -sb "$" | perl -ne '/^(\d+)/ and $q+=$1; END'`  find "$" $FIND_OPTS | cpio $CPIO_O_OPTS | pv -s $SIZE $PV_OPTS | (cd "$DEST" && cpio $CPIO_I_OPTS) 

Jemand, bitte testen Sie es.

+1 für dich! Ich fürchte, ich kann es nicht testen, aber es sieht vielversprechend aus! Gute Arbeit! BloodPhilia vor 13 Jahren 0
Was ist "pv"? Ist das [Pipe Viewer] (http://www.ivarch.com/programs/pv.shtml)? (Es ist nicht standardmäßig auf Ubuntu 10.04 installiert, daher habe ich es nicht). Stefan Lasiewski vor 13 Jahren 0
@Stefan Lasiewski Ja, das ist es. "apt-get install pv" Vi. vor 13 Jahren 1
Hinweis für Benutzer: Das Skript schlägt bei großen Dateien (> 2 GB) fehl. Vi. vor 12 Jahren 1
1
BloodPhilia

Ich schlage vor, dass Sie das hier überprüfen: http://bash.cyberciti.biz/guide/A_progress_bar_%28gauge_box%29#File_Copy_Progress_Bar_With_Dialog

Es sieht ziemlich ordentlich aus! =)

Es sieht wirklich ordentlich aus! Vielen Dank! dag729 vor 13 Jahren 0
@ dag729 Gern geschehen! ;) BloodPhilia vor 13 Jahren 0
"tt erhöht sich jedes Mal, wenn eine Datei in $ DEST kopiert wird" - schlecht, ich möchte, dass sie sowohl für viele kleine Dateien als auch für eine große Datei funktioniert. Und keine Preisbegrenzung. Vi. vor 13 Jahren 0
@Vi - vielleicht könntest du es ein bisschen anpassen? Es ist nur ein Beispiel für die Anzeige einer Fortschrittsleiste. BloodPhilia vor 13 Jahren 1
Nein, ich habe den Wrapper um "cpio | pv | cpio" geschrieben. Bald wird es hier veröffentlicht. Vi. vor 13 Jahren 0
1
saurabh

Try gcp. Should be available on Ubuntu.

Works (obwohl die Bearbeitung spezieller Dateien fehlt) Vi. vor 12 Jahren 0
Installiert gut auf Ubuntu Oneric, gab mir aber Fehler und stürzte auf einem einfachen `gcp file destination 'ab capdragon vor 12 Jahren 0