X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/4b54193df4e17c048a8a25b61c03b83a093003e3..0fc97e3eeb52abebc4d972e128ad206ab10386da:/user/rsync_tranches.sh?ds=inline diff --git a/user/rsync_tranches.sh b/user/rsync_tranches.sh index 4e27765..bcae90e 100644 --- a/user/rsync_tranches.sh +++ b/user/rsync_tranches.sh @@ -7,7 +7,7 @@ function rsync_tranches() { # Desc: Runs rsync in parallel across different files size ranges # Example: rsync_tranches -avu --progress --dry-run ./SOURCE/ ./DEST/ # Depends: rsync 3.2.7 - # Version: 0.0.2 + # Version: 0.1.1 local -a rsync_opts=(); local source dest; @@ -20,7 +20,13 @@ function rsync_tranches() { shift; ;; *) - if [ -z "$source" ]; then + ## If not a file or directory, assume option + if [[ ! -f "$1" ]] && [[ ! -d "$1" ]]; then + rsync_opts+=("$1"); + shift; + fi; + ## If valid file or directory, assume source or dest path + if [[ -z "$source" ]]; then source="$1"; else dest="$1"; @@ -38,15 +44,40 @@ function rsync_tranches() { # Tranche 1: 0 to 1MiB-1 rsync --min-size='0' --max-size='1MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + sleep 2; + + # Tranche 2: 1MiB to 2MiB-1 + rsync --min-size='1MiB' --max-size='2MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + + # Tranche 3: 2MiB to 4MiB-1 + rsync --min-size='2MiB' --max-size='4MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + + # Tranche 4: 4MiB to 8MiB-1 + rsync --min-size='4MiB' --max-size='8MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + + # Tranche 5: 8MiB to 16MiB-1 + rsync --min-size='8MiB' --max-size='16MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + + # Tranche 6: 16MiB to 32MiB-1 + rsync --min-size='16MiB' --max-size='32MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + + # Tranche 7: 32MiB to 64MiB-1 + rsync --min-size='32MiB' --max-size='64MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + + # Tranche 8: 64MiB to 128MiB-1 + rsync --min-size='64MiB' --max-size='128MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + + # Tranche 9: 128MiB to 256MiB-1 + rsync --min-size='128MiB' --max-size='256MiB-1' "${rsync_opts[@]}" "$source" "$dest" & - # Tranche 2: 1MiB to 10MiB-1 - rsync --min-size='1MiB' --max-size='10MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + # Tranche 10: 256MiB to 512MiB-1 + rsync --min-size='256MiB' --max-size='512MiB-1' "${rsync_opts[@]}" "$source" "$dest" & - # Tranche 3: 10MiB to 100MiB-1 - rsync --min-size='10MiB' --max-size='100MiB-1' "${rsync_opts[@]}" "$source" "$dest" & + # Tranche 11: 512MiB to 1024MiB-1 + rsync --min-size='512MiB' --max-size='1024MiB-1' "${rsync_opts[@]}" "$source" "$dest" & - # Tranche 4: Greater than 100MiB - rsync --min-size='100MiB' --max-size='8192PiB-1' "${rsync_opts[@]}" "$source" "$dest" & + # Tranche 12: Greater than 1024MiB + rsync --min-size='1024MiB' --max-size='8192PiB-1' "${rsync_opts[@]}" "$source" "$dest" & wait # Wait for all rsync processes to complete };