tl;dr:
Encrypt:
$ tar cz folder_to_encrypt | openssl enc -aes-256-cbc -e > out.tar.gz.enc
Decrypt:
$ openssl enc -aes-256-cbc -d -in out.tar.gz.enc | tar xz
This is for example how I make a secure postgresql dump: pg_dump database-name | gzip | openssl enc -aes-256-cbc -kfile .backuppassphrase -e > "db_backups/dump.psql.gz.enc"
and extract it with: openssl enc -aes-256-cbc -d -in dump.psql.gz.enc | gzip -d > dump.psql
Encrypt:
$ gpg --encrypt out.tar.gz
Decrypt:
$ gpg --decrypt out.tar.gz