# Compressing and encrypting file systems for backups

I am currently backing up remote OS' while preserving the permissions using rsync:

rsync -aAX --numeric-ids --delete ... root@X.X.X.X:/ /backup/server/


Now I want to backup the backup to a third party. I currently have:

tar --xattrs -czpf - "/backup/server/" | openssl enc -aes-256-cbc -a -salt -pass pass:"\$KEY" -out "/backup/server.encr"


Which will compress and encrypt while preserving permissions.

I would eventually like to write this in Go but it seems a bit complicated the preserving of permissions are there some alternative all in one libraries to do this?