0

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/
shantanuo
  • 3,459
  • 8
  • 47
  • 64

2 Answers2

1

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

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81
0

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.

womble
  • 95,029
  • 29
  • 173
  • 228