Compress a file over SSH using tar

Create a local archive from a remote folder

ssh user@host tar czf - /source_path/ > /localdestination/archive.tar.gz

Restore a local archive to a remote folder

cat /localdestination/archive.tar.gz | ssh user@host "tar zxvf -"
# - or -
cat /localdestination/archive.tar.gz | ssh user@host "cd /dest_path/; tar zxvf -"

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.