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?

2 Answers 2


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.

  • 5
    Although, if you are syncing to a web server and that server caches HTML, you might not want to use --delete, since visitors on a stale page might request an asset that no longer exists.
    – Jackson
    May 24, 2016 at 21:56
  • @Jackson a clean process will not include variable data like caches or configs in the sources. Nov 17, 2018 at 7:40
  • In some cases I have deal with servers outside of my domain that don't have rsync but have scp. Is there a comparable solution, even if it needs a few lines of scripting?
    – jacobq
    Dec 21, 2018 at 14:58
  • The answer is helpful, but the question was can this be achieved with scp itself.
    – Mladen B.
    Nov 2, 2019 at 20:02
  • @MladenB. How it can be achieved by scp? Dec 13, 2019 at 4:48

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
       sshpass -p "" scp "$file" "root@$IP://usr/local/www/current/$file"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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