Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mbuffer for smoother transfers #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions bin/snap-sync
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ if [[ $? -ne 0 ]]; then
donotify=1
fi

doprogress=0
which pv &> /dev/null
if [[ $? -ne 0 ]]; then
doprogress=1
unset doprogress
which mbuffer &> /dev/null
if [[ $? -eq 0 ]]; then
doprogress="mbuffer -m 1G -v 3"
else
which pv &> /dev/null
if [[ $? -eq 0 ]]; then
doprogress=pv
fi
fi

error() {
Expand Down Expand Up @@ -465,8 +470,8 @@ for x in $selected_configs; do

if [[ -z "$old_num" ]]; then
printf "Sending first snapshot for '%s' configuration...\n" "$x" | tee $PIPE
if [[ $doprogress -eq 0 ]]; then
btrfs send "$new_snap" | pv | $ssh btrfs receive "$backup_location" &>/dev/null
if [[ -v doprogress ]]; then
btrfs send "$new_snap" | $doprogress | $ssh btrfs receive "$backup_location" &>/dev/null
else
btrfs send "$new_snap" | $ssh btrfs receive "$backup_location" &>/dev/null
fi
Expand All @@ -478,8 +483,8 @@ 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.

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