Let's say you have something like this on your media structure.
pub/
|-- errors
|-- media
| |-- catalog
| | |-- category
| | |-- placeholder
| | |-- product
| | | |-- a
| | | |-- b
| | | |-- c
| | | |-- cache
| | | |-- placeholder
| |-- placeholder
| | `-- placeholder
| | `-- default
| |-- tmp
| | |-- catalog
| | | `-- product
| | `-- design
| | `-- file
| `-- wysiwyg
|-- opt
| `-- magento
| `-- var
`-- static
|-- adminhtml
`-- frontend
Some of these directories may take a huge amout of disk space and they don't need to be compressed. It's the case for pub/media/catalog/product/cache
and pub/media/tmp
directories, for instance.
tar --exclude='catalog/product/cache' --exclude='tmp' -czpf media.tar.gz pub/media