ssh tar way to transfer files (suitable for sufficient bandwidth to transfer large amounts of small files scene)

LAN speed fast, but when you want to transfer a large number of small files if you are still using scp, since each file transfer is completed requires independent confirmation of the transfer is complete, so you can not make full use of the bandwidth.

Ssh tar and exactly corresponding to the transmission mode to the scene, all the files into a stream, discontinuous transmission, the transmission acknowledgment linux save process.

spawn bash -c "ssh ${username}@${ip} '(cd ${src_folder_path};tar -cf - ${src_folder_name} | cat)' | tar xfv - -C ${dst_path}"
expect {
"(yes/no)?" { send "yes\r";exp_continue } 
"*assword:*" { send "${password}\r" }
}

 

spawn bash -c "ssh ${username}@${ip} '(cd ${src_folder_path};tar -cf - ${src_folder_name} | cat)' | tar xfv - -C ${dst_path}"
expect {
"(yes/no)?" { send "yes\r";exp_continue } 
"*assword:*" { send "${password}\r" }
}

Guess you like

Origin www.cnblogs.com/dongzhiquan/p/ssh_tar_transfer.html