Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

SCP does not seem to preserve ownership stamps even if used with -p option.

scp -p /mysql/serv/data_summary.* some_server:/mysql/test/

The files are owned by mysql and I want the same ownership to be assigned on the destination server. I need to copy files as root on both servers due to some admin issues. I can not change to mysql@

share|improve this question
up vote 17 down vote accepted

Try to use rsync, it has a lot more benefits besides keeping ownership, permissions and incremental copies:

rsync -av source

Besides rsync, using ssh, should work where scp works.

share|improve this answer
ssh supports -i myfile.pem and rsync does not seem to have -i option – shantanuo Mar 20 '12 at 8:13
@shantanuo: Use rsync -e 'ssh -i myfile.pem' -insert_other_rsync_options_here – Janne Pikkarainen Mar 20 '12 at 8:25

That is correct. "-p" does not do that. See the man page:

     -p      Preserves modification times, access times, and modes from the
             original file.

Notice it says times and modes, NOT user/group ownership. You will have better luck with "rsync", as it has various capabilities around preserving permissions when copying between disparate systems. "-p" in rsync, for example.

share|improve this answer

Your Answer


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.