diff --git a/prsync b/prsync index 1b61513..2dfbfaf 100755 --- a/prsync +++ b/prsync @@ -5,7 +5,7 @@ cat << EOF A wrapper around rsync which partitions the input files to blocks of roughly equal sizes and transfers them in multiple streams in parallel. -Usage: $(basename $0) [rsync flags] ... +Usage: $(basename $0) [opt] ... Options: Number of blocks/transfer streams. Source files (potentially multiple files). @@ -14,12 +14,14 @@ Options: -h, --help Print this message. -n, --dry-run Do not transfer any data. -r, --recursive Copy directories recursively + -s, --streams Use parallel streams. -v, --verbose List files as they are transferred. EOF } # Parse arguments declare -a positional flags_rsync flags_du +declare -i num_streams=1 positional=() flags_rsync=('-R' '-v' '--info=stats0,misc0,flist0') flags_du=('-b') @@ -49,6 +51,11 @@ while [[ $# -gt 0 ]]; do flag_recursive=1 shift ;; + '-s'|'--streams') + num_streams=$2 + shift + shift + ;; '-v'|'--verbose') flag_verbose=1 shift @@ -66,13 +73,11 @@ done declare -i num_args num_args=${#positional[@]} -[[ $num_args -lt 3 ]] && usage && exit 1 +[[ $num_args -lt 2 ]] && usage && exit 1 # Parse -declare -i num_streams -num_streams=${positional[0]} -if [[ $num_streams -eq 0 ]]; then - echo "Error: invalid value for (${positional[0]})" >&2 +if [[ $num_streams -lt 1 ]]; then + echo "Error: invalid number of streams" >&2 exit 1 fi @@ -88,7 +93,7 @@ function walk_dir { done } declare -a src -for path in "${positional[@]:1:num_args-2}"; do +for path in "${positional[@]:0:num_args-1}"; do if [[ -L ${path} ]] && [[ $flag_copy_links -eq 0 ]]; then continue elif [[ -f ${path} ]]; then