To achieve the task with ssh and scp (instead of rsync):
Solution
Lets break into 2 steps :
1. Create directory if missing:
ssh [email protected] "mkdir -p /data/install/somefolder"
2. Copy to it:
scp -r /data/install/somefolder [email protected]:/data/install/somefolder
Put them together
server="[email protected]"
destiny="/data/install/somefolder"
src="/data/install/somefolder"
ssh "$server" "mkdir -p $destiny" && scp -r "$src" "$server:$destiny"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…