Skip to content

Instantly share code, notes, and snippets.

@jgwill
Last active December 23, 2020 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgwill/5a78d6eb6184c8c57a73a39d1f1c5c73 to your computer and use it in GitHub Desktop.
Save jgwill/5a78d6eb6184c8c57a73a39d1f1c5c73 to your computer and use it in GitHub Desktop.
Can we tar achive via SSH? 201223171246

#Can we tar achive via SSH?

YES

This script does :

  • connect to the host
  • change dir to the desired
  • extract into local dir desired
export ssh_remote_host=myhost.com
export remote_user=me
export remote_dir_root=/www
export local_mirror=/c/usr/src/mymirrordir

cd $local_mirror
ssh $remote_user@$ssh_remote_host 'cd $remote_dir_root &&tar czf - *' | tar xzf -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment