Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The following scp is working as expected.

scp /home/admin/* root@ec2-50-112-212-73:/

But I need a command that will create the required folder structure on destination server if it does not already exist.

Update:

I can do it in 2 steps as shown below. I will like to know if there is any other way.

ssh root@ec2-50-112-212-73  " mkdir -p /home/admin/ "
scp  -r /home/admin/* root@ec2-50-112-212-73:/home/admin/
share|improve this question

closed as off topic by quanta, pfo, womble, Chopper3, Wesley Jun 27 '12 at 1:21

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

4  
Do you mean scp -r? –  quanta Jun 26 '12 at 11:00
    
No. equivalent to mkdir -p /home/admin/ on remote server, that will work with scp or tar –  shantanuo Jun 26 '12 at 11:07
    
That's what -r for: Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal. –  ott-- Jun 26 '12 at 11:23
add comment

2 Answers

up vote 1 down vote accepted

You might be better off using rsync:

rsync -av -R -f"+ */" -f"- *" /home/admin/* root@ec2-50-112-212-73:/

This will only create the directories on the other (ec2) side

share|improve this answer
    
Wouldn't you also need the -R option in order to create /home/admin/? –  Oliver Jun 26 '12 at 11:20
    
Ah, yes, thought he didn't want that. Thanks. –  Bart De Vos Jun 26 '12 at 11:24
add comment

scp -r /home/admin/ root@ec2-50-112-212-73:/home/admin/ will work, assuming you don't specifically want to copy just the non-dotfiles in /home/admin.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.