Backup Raspberry Pi SD Card on MacOS to compressed image

Caution:The used UNIX command is 'dd'. Try 'man dd'.
In the vernacular it is also called 'disk destroyer' for reasons.

List Disks and backup a compressed image to /downloads:

$ diskutil list

/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         500.3 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         500.0 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +500.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            481.5 GB   disk1s1
   2:                APFS Volume Preboot                 48.9 MB    disk1s2
   3:                APFS Volume Recovery                510.6 MB   disk1s3
   4:                APFS Volume VM                      3.2 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.9 GB    disk2
   1:             Windows_FAT_32 NO NAME                 331.4 MB   disk2s1
   2:                      Linux                         15.6 GB    disk2s2

$ sudo dd bs=4m if=/dev/disk2 | gzip > /Users/MyHome/Downloads/myImge.img.gz

(ctrl + t)

load: 1.70  cmd: dd 12841 uninterruptible 0.00u 39.28s
989+0 records in
985+8 records out
4148166656 bytes transferred in 901.976381 secs (4598975 bytes/sec)

bs=* defines the read/write block size. The default value is 512kb. I've fiddled around with values between 2 and 4,..n mb but can't get a better speed than shown above.
Press Ctrl+t to display a actual statistic of the transfer.

and back:

gzip -dc  /Users/MyHome/Downloads/myImge.img.gz| dd bs=4m of=/dev//dev/disk2

Scripts:

backup.sh

$ diskutil list

read -p "Enter device name (for example for device /dev/disk2 enter disk2): " device
diskutil unmountDisk /dev/$device

write_location=~/baaahs_lights_server_`date +%d%m%Y`.img
echo
echo "Writing compressed image to $write_location"
sudo dd bs=1m if=/dev/r$device | gzip > $write_location

restore.sh

#!/usr/bin/env bash

diskutil list

read -p "Enter device name (for example for device /dev/disk2 enter disk2): " device
diskutil unmountDisk /dev/$device

read -p "Enter the gzip compressed image path: " image_path
gzip -dc $image_path | dd bs=4m of=/dev/r$device