Scripts: add scp_turbo script
This commit is contained in:
parent
a32f42d404
commit
388b275bd0
1 changed files with 36 additions and 0 deletions
36
bin/scp_turbo
Executable file
36
bin/scp_turbo
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
print_help() {
|
||||
cat <<HELP
|
||||
$(basename "$0"): A fast transfer for single files
|
||||
- Supports input pipes! (useful for gpg pipes)
|
||||
- 2x faster than scp, right around rsync speeds
|
||||
- Shows a progress bar!
|
||||
|
||||
Examples:
|
||||
$ scp_turbo orca dotfiles.tgz.gpg /dev/shm/dotfiles.tgz.gpg
|
||||
$ cat dotfiles.tgz.gpg | scp_turbo orca /dev/shm/dotfiles.tgz.gpg
|
||||
$ tar cz kattis | gpg -e -r emiliko@mami2.moe | scp_turbo orca /dev/shm/kattis.tgz.gpg
|
||||
HELP
|
||||
|
||||
}
|
||||
|
||||
if [[ "$1" == --help || "$1" == -h ]]; then
|
||||
print_help
|
||||
exit 1
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
declare -r remote="$1"
|
||||
declare -r to="$2"
|
||||
|
||||
pv | ssh -o ClearAllForwardings=yes "$remote" "cat > '$to'"
|
||||
elif [[ $# -eq 3 ]]; then
|
||||
declare -r remote="$1"
|
||||
declare -r from="$2"
|
||||
declare -r to="$3"
|
||||
|
||||
cat "$from" \
|
||||
| pv -s $(stat -c %s "$from") \
|
||||
| ssh -o ClearAllForwardings=yes "$remote" "cat > '$to'"
|
||||
else
|
||||
print_help
|
||||
exit 2
|
||||
fi
|
Loading…
Reference in a new issue