Skip to content

Commit 31ae1e2

Browse files
authored
Merge pull request #93 from wesbarnett/feature/progress
Use pv for progress if it is installed
2 parents 6e70f0e + 0c9c589 commit 31ae1e2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

bin/snap-sync

+16-3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ if [[ $? -ne 0 ]]; then
4848
donotify=1
4949
fi
5050

51+
doprogress=0
52+
which pv &> /dev/null
53+
if [[ $? -ne 0 ]]; then
54+
doprogress=1
55+
fi
56+
5157
error() {
5258
printf "==> ERROR: %s\n" "$@"
5359
notify_error 'Error' 'Check journal for more information.'
@@ -459,8 +465,11 @@ for x in $selected_configs; do
459465

460466
if [[ -z "$old_num" ]]; then
461467
printf "Sending first snapshot for '%s' configuration...\n" "$x" | tee $PIPE
462-
btrfs send "$new_snap" | $ssh btrfs receive "$backup_location" &>/dev/null
463-
468+
if [[ $doprogress -eq 0 ]]; then
469+
btrfs send "$new_snap" | pv | $ssh btrfs receive "$backup_location" &>/dev/null
470+
else
471+
btrfs send "$new_snap" | $ssh btrfs receive "$backup_location" &>/dev/null
472+
fi
464473
else
465474

466475
printf "Sending incremental snapshot for '%s' configuration...\n" "$x" | tee $PIPE
@@ -469,7 +478,11 @@ for x in $selected_configs; do
469478
# is an identical subvolume to the old snapshot at the receiving
470479
# location where it can get its data. This helps speed up the transfer.
471480

472-
btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location"
481+
if [[ $doprogress -eq 0 ]]; then
482+
btrfs send -c "$old_snap" "$new_snap" | pv | $ssh btrfs receive "$backup_location"
483+
else
484+
btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location"
485+
fi
473486

474487
if [[ $keep == "yes" ]]; then
475488
printf "Modifying data for old local snapshot for '%s' configuration...\n" "$x" | tee $PIPE

0 commit comments

Comments
 (0)