diff --git a/aurora/backup-to-portable b/aurora/backup-to-portable index 837b85f..88f5cee 100755 --- a/aurora/backup-to-portable +++ b/aurora/backup-to-portable @@ -111,10 +111,24 @@ else fi 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 -btrfs send $PARENT_FLAG "$BTRFS_TOP/$SNAP_DIR/$SNAP_NAME" \ - | btrfs receive "$BACKUP_MOUNT/backups/" \ - || die "btrfs send/receive failed" +if command -v pv &>/dev/null && [ -n "$SNAP_SIZE" ] && [ "$SNAP_SIZE" -gt 0 ] 2>/dev/null; then + log "Estimated snapshot size: $(numfmt --to=iec "$SNAP_SIZE")" + 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" diff --git a/aurora/restore-from-portable b/aurora/restore-from-portable index c709e7c..fab23dd 100755 --- a/aurora/restore-from-portable +++ b/aurora/restore-from-portable @@ -207,8 +207,21 @@ full_restore() { echo "Receiving snapshot from backup drive..." local restore_name="home-restoring-$(date +%Y%m%d-%H%M%S)" - btrfs send "$snap_path" | btrfs receive "$BTRFS_TOP/snapshots/" \ - || die "btrfs receive failed" + # Estimate size for progress display (btrfs send streams uncompressed, + # 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. echo "Creating writable home from snapshot..."