32

I'm using below command to transfer files cross server

scp -rc blowfish /source/directory/* username@domain.net:/destination/directory

Is there a way to transfer only files modified files just like update command for cp?

mob
  • 5
  • 1
Passionate Engineer
  • 513
  • 1
  • 6
  • 12

2 Answers2

61

rsync is your friend.

rsync -ru /source/directory/* username@domain.net:/destination/directory

If you want it to delete files at the destination that no longer exist at the source, add the --delete option.

Cristian Ciupitu
  • 6,226
  • 2
  • 41
  • 55
Flup
  • 7,688
  • 1
  • 31
  • 43
8

Generally one asks for scp because there is a reason. I.e. can't install rsyncd on the target.

files=`find . -newermt "-3600 secs"`

for file in $files
do
       sshpass -p "" scp "$file" "root@$IP://usr/local/www/current/$file"
done
Dave M
  • 4,494
  • 21
  • 30
  • 30