title: How to script scp -r copy?
body: <p>I can't seem to be able to convince scp to behave.</p>
  
  <p>For test data</p>
  
  <pre><code>ubuntu@domU-12-31-38-00-D4-F1:/tmp$ find /tmp/a1/
  /tmp/a1/
  /tmp/a1/a2
  /tmp/a1/a2/a3
  </code></pre>
  
  <p>On issuing the command</p>
  
  <pre><code>ubuntu@domU-12-31-38-00-D4-F1:/tmp$ scp -r /tmp/a1 domU-12-31-38-00-E2-52.compute-1.internal:/tmp/a1
  </code></pre>
  
  <p>I would expect the same directory structure created on domU-12-31-38-00-E2-52.compute-1.internal, whatever the directory /tmp/a1 exists on target host or not. Instead, what scp actually creates is the following structure (if /tmp/a1 exists on target host)</p>
  
  <pre><code>ubuntu@domU-12-31-38-00-D4-F1:/tmp$ ssh domU-12-31-38-00-E2-52.compute-1.internal find /tmp/a1 
  /tmp/a1
  /tmp/a1/a1
  /tmp/a1/a1/a2
  /tmp/a1/a1/a2/a3
  </code></pre>
  
  <p>How can scp be forced to copy into given directory as the root of the operation?</p>
  
  <p>Later on I would like to script this operation so that given directory path on master I can call a script that will replicate the same directory structure to all slaves. Please note that rsync behavior (at least from what I've tested) is the same in this manner.</p>
  
  <p>Thank you,
  Maxim.</p>