Deploy from Windows to Linux using SSH

Standard

I generally develop on Windows and deploy to Linux servers where our Apache and Tomcat instances are running. The following single command is a bit of magic. It does the following:

  1. Tars up all the files forĀ mywebapp
  2. Transfers them using ssh
  3. Extracts them to the correct location and as the correct user (builduser in this example) on the deployment machine.
tar -C c:/opt/apache2/htdocs/mywebapp -cvf - . | ssh philip.murphy@my-build-server.com "sudo -u builduser tar -C /var/www/html/mywebapp -xmf -"
Advertisements