Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

scp with password less authentication is working fine but if delete a file on the source it will not get replicated ie the destination directory is not completely replaced with source. I can see the new files or modifications are properly get replicated.

scp -r /user/local/img root@192.168.18.73:/user/local/img
share|improve this question

3 Answers 3

up vote 5 down vote accepted

scp is only a copy tool, so if you have to use scp, your only real choice is to empty the destination directory tree first.

Alternatively, you should probably look into using rsync, this will run over ssh using the passwordless setup you have now, and has many advantages (it can replicate deletes, only transfers changed data so copies are quicker, and can compress data during transfer). If you change your command to this one, you should get the results that you want (although test it first to make 100% sure it does what you're looking for!):

rsync -avz --del /user/local/img root@192.168.18.73:/user/local/img

share|improve this answer

scp works much like standard cp - it copies what you tell it to copy. Your command above says that it should copy the local folder /usr/local/img to /usr/local/img on the remote server; if the remote folder already exists, then it'll copy to /usr/local/img/img.

share|improve this answer

scp is much the same as cp it doesn't delete destination files if the source has been deleted . If you want to keep source and destination directories in sync then rsync is the way forward.

rsync -avz --delete /user/local/img root@192.168.18.73:/user/local/img

you can also use rsync over ssh

rsync -avz -e ssh --delete /user/local/img root@192.168.18.73:/user/local/img
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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