Skip to content
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
24 changes: 22 additions & 2 deletions snazzer-receive
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ do_send() {
DEST_SUBVOL="."
DEST_SUBVOL_ESC="."
fi
if [ "$PROGRESS" = "1" ]; then
EXTRA_ARGS="$(which pv) -trab | "
else
EXTRA_ARGS=""
fi
SNAP_NAME=$(basename "$SNAP_ABSPATH")
# Can't use do_ssh below, we must stream ssh output to btrfs receive
# Don't forget to copy the lines below into dry_send() between CMD heredoc
Expand All @@ -176,10 +181,12 @@ do_send() {
if [ -n "$SNAP_PARENT_PATH" ]; then
# Don't forget to copy the lines below into dry_send() between CMD2 heredoc
$SUDO btrfs send "$SNAP_ABSPATH" -p "$SNAP_PARENT_PATH" | \
eval $EXTRA_ARGS \
$SUDO btrfs receive "$DEST_SUBVOL/.snapshotz/.incomplete"
else
# Don't forget to copy the lines below into dry_send() between CMD3 heredoc
$SUDO btrfs send "$SNAP_ABSPATH" | \
eval $EXTRA_ARGS \
$SUDO btrfs receive "$DEST_SUBVOL/.snapshotz/.incomplete"
fi
else
Expand Down Expand Up @@ -435,6 +442,12 @@ do_host() {
echo "ERROR: This should never happen" >&2
exit 127
fi
if [ "$PROGRESS" = "1" ]; then
if [ ! -e "$(which pv)" ]; then
echo "ERROR: For progress display you need pv installed. Exiting" >&2
exit 127
fi
fi
NUM_SUBVOL=0
LIST_ERR=$(mktemp)
LIST_OUT=$(mktemp)
Expand Down Expand Up @@ -466,6 +479,7 @@ do_host() {

DRY_RUN=0
LOCAL_RUN=0
PROGRESS=0

while [ "$(echo "$1" | grep -c "^-")" != "0" -a "$LOCAL_RUN" != "1" ]
do
Expand Down Expand Up @@ -498,6 +512,10 @@ HERE
DRY_RUN=1;
shift
;;
--progress )
PROGRESS=1;
shift
;;
-- )
LOCAL_RUN=1
;;
Expand Down Expand Up @@ -532,9 +550,9 @@ Receive snapshots from remote host via ssh:

Receive snapshots from local filesystem:

snazzer-receive [--dry-run] -- --all [/path/to/btrfs/mountpoint]
snazzer-receive [--progress] [--dry-run] -- --all [/path/to/btrfs/mountpoint]

snazzer-receive [--dry-run] -- /local/subvol1 [/subvol2 [..]]
snazzer-receive [--progress] [--dry-run] -- /local/subvol1 [/subvol2 [..]]

=head1 DESCRIPTION

Expand Down Expand Up @@ -576,6 +594,8 @@ file usually at C<$HOME/.ssh/config>.

snazzer-receive --man-markdown > snazzer-manpage.md

=item B<--progress>: Show progress while sending the snapshots

=back

=head1 ENVIRONMENT
Expand Down