Skip to content

Instantly share code, notes, and snippets.

@dobrokot
Created March 13, 2014 10:33
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 dobrokot/9525920 to your computer and use it in GitHub Desktop.
Save dobrokot/9525920 to your computer and use it in GitHub Desktop.
copy directory fron host to (local or other) host
#!/usr/bin/env bash
set -eu
if [ "." == "$2" ]; then
CMD="tar -xvzf -";
else
case "$2" in
"dev") H="kotic.dev.zla.net" ;;
"gen") H="kotic-gen.proto.zla.net" ;;
*) H="$2" ;;
esac
CMD="ssh $H 'tar -xvzf -'"
fi
echo "ssh $(hostname --fqdn) 'cd $(dirname $(readlink -f $1)) && tar -cf- $(basename $1) | gzip -1' | $CMD "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment