Add pv
This commit is contained in:
parent
627efbea0a
commit
0f9cabb2ff
2 changed files with 32 additions and 5 deletions
|
|
@ -111,10 +111,24 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Sending snapshot to backup drive..."
|
log "Sending snapshot to backup drive..."
|
||||||
|
|
||||||
|
# Estimate size for progress display (btrfs send streams uncompressed,
|
||||||
|
# so use disk usage as a rough lower bound)
|
||||||
|
SNAP_SIZE=$(btrfs filesystem du -s --raw "$BTRFS_TOP/$SNAP_DIR/$SNAP_NAME" 2>/dev/null \
|
||||||
|
| awk 'NR==2 {print $1}')
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
btrfs send $PARENT_FLAG "$BTRFS_TOP/$SNAP_DIR/$SNAP_NAME" \
|
if command -v pv &>/dev/null && [ -n "$SNAP_SIZE" ] && [ "$SNAP_SIZE" -gt 0 ] 2>/dev/null; then
|
||||||
| btrfs receive "$BACKUP_MOUNT/backups/" \
|
log "Estimated snapshot size: $(numfmt --to=iec "$SNAP_SIZE")"
|
||||||
|| die "btrfs send/receive failed"
|
btrfs send $PARENT_FLAG "$BTRFS_TOP/$SNAP_DIR/$SNAP_NAME" \
|
||||||
|
| pv -pterab -s "$SNAP_SIZE" \
|
||||||
|
| btrfs receive "$BACKUP_MOUNT/backups/" \
|
||||||
|
|| die "btrfs send/receive failed"
|
||||||
|
else
|
||||||
|
btrfs send $PARENT_FLAG "$BTRFS_TOP/$SNAP_DIR/$SNAP_NAME" \
|
||||||
|
| btrfs receive "$BACKUP_MOUNT/backups/" \
|
||||||
|
|| die "btrfs send/receive failed"
|
||||||
|
fi
|
||||||
|
|
||||||
log "Snapshot sent successfully"
|
log "Snapshot sent successfully"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,8 +207,21 @@ full_restore() {
|
||||||
echo "Receiving snapshot from backup drive..."
|
echo "Receiving snapshot from backup drive..."
|
||||||
local restore_name="home-restoring-$(date +%Y%m%d-%H%M%S)"
|
local restore_name="home-restoring-$(date +%Y%m%d-%H%M%S)"
|
||||||
|
|
||||||
btrfs send "$snap_path" | btrfs receive "$BTRFS_TOP/snapshots/" \
|
# Estimate size for progress display (btrfs send streams uncompressed,
|
||||||
|| die "btrfs receive failed"
|
# so use disk usage as a rough lower bound)
|
||||||
|
local snap_size
|
||||||
|
snap_size=$(btrfs filesystem du -s --raw "$snap_path" 2>/dev/null \
|
||||||
|
| awk 'NR==2 {print $1}')
|
||||||
|
|
||||||
|
if command -v pv &>/dev/null && [ -n "$snap_size" ] && [ "$snap_size" -gt 0 ] 2>/dev/null; then
|
||||||
|
echo "Estimated snapshot size: $(numfmt --to=iec "$snap_size")"
|
||||||
|
btrfs send "$snap_path" | pv -pterab -s "$snap_size" \
|
||||||
|
| btrfs receive "$BTRFS_TOP/snapshots/" \
|
||||||
|
|| die "btrfs receive failed"
|
||||||
|
else
|
||||||
|
btrfs send "$snap_path" | btrfs receive "$BTRFS_TOP/snapshots/" \
|
||||||
|
|| die "btrfs receive failed"
|
||||||
|
fi
|
||||||
|
|
||||||
# The received snapshot is read-only. Create a writable snapshot from it.
|
# The received snapshot is read-only. Create a writable snapshot from it.
|
||||||
echo "Creating writable home from snapshot..."
|
echo "Creating writable home from snapshot..."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue