tar cf - ./ --exclude=pub/media/catalog/* --exclude=pub/media/* --exclude=pub/media/backup/* --exclude=pub/media/import/* --exclude=pub/media/tmp/* --exclude=pub/static/* --exclude=var/* --exclude=private --exclude=tests | gzip > /tmp/`date +%s`.code.tar.gz
After execution you will be able to find dump in the directory /tmp
ls -laht /tmp/*.code.tar.gz
Your dump will be shown at the top of the listed dumps.