Skip to content

Commit

Permalink
Merge pull request #93 from wesbarnett/feature/progress
Browse files Browse the repository at this point in the history
Use pv for progress if it is installed
  • Loading branch information
wesbarnett authored Jan 24, 2021
2 parents 6e70f0e + 0c9c589 commit 31ae1e2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bin/snap-sync
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ if [[ $? -ne 0 ]]; then
donotify=1
fi

doprogress=0
which pv &> /dev/null
if [[ $? -ne 0 ]]; then
doprogress=1
fi

error() {
printf "==> ERROR: %s\n" "$@"
notify_error 'Error' 'Check journal for more information.'
Expand Down Expand Up @@ -459,8 +465,11 @@ for x in $selected_configs; do

if [[ -z "$old_num" ]]; then
printf "Sending first snapshot for '%s' configuration...\n" "$x" | tee $PIPE
btrfs send "$new_snap" | $ssh btrfs receive "$backup_location" &>/dev/null

if [[ $doprogress -eq 0 ]]; then
btrfs send "$new_snap" | pv | $ssh btrfs receive "$backup_location" &>/dev/null
else
btrfs send "$new_snap" | $ssh btrfs receive "$backup_location" &>/dev/null
fi
else

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

btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location"
if [[ $doprogress -eq 0 ]]; then
btrfs send -c "$old_snap" "$new_snap" | pv | $ssh btrfs receive "$backup_location"
else
btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location"
fi

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

0 comments on commit 31ae1e2

Please sign in to comment.